Mercurial > repos > prog > lcmsmatching
comparison KeggCompound.R @ 1:253d531a0193 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
author | prog |
---|---|
date | Sat, 03 Sep 2016 17:02:01 -0400 |
parents | e66bb061af06 |
children |
comparison
equal
deleted
inserted
replaced
0:e66bb061af06 | 1:253d531a0193 |
---|---|
18 | 18 |
19 compounds <- list() | 19 compounds <- list() |
20 | 20 |
21 # Define fields regex | 21 # Define fields regex |
22 regex <- character() | 22 regex <- character() |
23 regex[[RBIODB.NAME]] <- "^NAME\\s+([^,;]+)" | 23 regex[[BIODB.NAME]] <- "^NAME\\s+([^,;]+)" |
24 regex[[RBIODB.CHEBI.ID]] <- "^\\s+ChEBI:\\s+(\\S+)" | 24 regex[[BIODB.CHEBI.ID]] <- "^\\s+ChEBI:\\s+(\\S+)" |
25 regex[[RBIODB.LIPIDMAPS.ID]] <- "^\\s+LIPIDMAPS:\\s+(\\S+)" | 25 regex[[BIODB.LIPIDMAPS.ID]] <- "^\\s+LIPIDMAPS:\\s+(\\S+)" |
26 | 26 |
27 for (text in contents) { | 27 for (text in contents) { |
28 | 28 |
29 # Create instance | 29 # Create instance |
30 compound <- KeggCompound$new() | 30 compound <- KeggCompound$new() |
48 # ACCESSION | 48 # ACCESSION |
49 { | 49 { |
50 # ENZYME ID | 50 # ENZYME ID |
51 g <- str_match(s, "^ENTRY\\s+EC\\s+(\\S+)") | 51 g <- str_match(s, "^ENTRY\\s+EC\\s+(\\S+)") |
52 if ( ! is.na(g[1,1])) | 52 if ( ! is.na(g[1,1])) |
53 compound$setField(RBIODB.ACCESSION, paste('ec', g[1,2], sep = ':')) | 53 compound$setField(BIODB.ACCESSION, paste('ec', g[1,2], sep = ':')) |
54 | 54 |
55 # ENTRY ID | 55 # ENTRY ID |
56 else { | 56 else { |
57 g <- str_match(s, "^ENTRY\\s+(\\S+)\\s+Compound") | 57 g <- str_match(s, "^ENTRY\\s+(\\S+)\\s+Compound") |
58 if ( ! is.na(g[1,1])) | 58 if ( ! is.na(g[1,1])) |
59 compound$setField(RBIODB.ACCESSION, paste('cpd', g[1,2], sep = ':')) | 59 compound$setField(BIODB.ACCESSION, paste('cpd', g[1,2], sep = ':')) |
60 | 60 |
61 # OTHER ID | 61 # OTHER ID |
62 else { | 62 else { |
63 g <- str_match(s, "^ENTRY\\s+(\\S+)") | 63 g <- str_match(s, "^ENTRY\\s+(\\S+)") |
64 if ( ! is.na(g[1,1])) | 64 if ( ! is.na(g[1,1])) |
65 compound$setField(RBIODB.ACCESSION, g[1,2]) | 65 compound$setField(BIODB.ACCESSION, g[1,2]) |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 # ORGANISM | 69 # ORGANISM |
70 g <- str_match(s, "^ORGANISM\\s+(\\S+)") | 70 g <- str_match(s, "^ORGANISM\\s+(\\S+)") |
71 if ( ! is.na(g[1,1])) | 71 if ( ! is.na(g[1,1])) |
72 compound$setField(RBIODB.ACCESSION, paste(g[1,2], compound$getField(RBIODB.ACCESSION), sep = ':')) | 72 compound$setField(BIODB.ACCESSION, paste(g[1,2], compound$getField(BIODB.ACCESSION), sep = ':')) |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 compounds <- c(compounds, compound) | 76 compounds <- c(compounds, compound) |
77 } | 77 } |
78 | 78 |
79 # Replace elements with no accession id by NULL | 79 # Replace elements with no accession id by NULL |
80 compounds <- lapply(compounds, function(x) if (is.na(x$getField(RBIODB.ACCESSION))) NULL else x) | 80 compounds <- lapply(compounds, function(x) if (is.na(x$getField(BIODB.ACCESSION))) NULL else x) |
81 | 81 |
82 # If the input was a single element, then output a single object | 82 # If the input was a single element, then output a single object |
83 if (drop && length(contents) == 1) | 83 if (drop && length(contents) == 1) |
84 compounds <- compounds[[1]] | 84 compounds <- compounds[[1]] |
85 | 85 |