Mercurial > repos > fgiacomoni > hmdb_ms_search
comparison lib/hmdb.pm @ 4:6091a80df951 draft
planemo upload commit e2dfb6f7afeeb7767ef83e9e2c3a2d3e6a94ae98
author | fgiacomoni |
---|---|
date | Fri, 19 Jan 2018 09:38:17 -0500 |
parents | 6d0a0f8f672a |
children | 7ed37640fe2a |
comparison
equal
deleted
inserted
replaced
3:505956db90c5 | 4:6091a80df951 |
---|---|
269 my %features = () ; | 269 my %features = () ; |
270 | 270 |
271 # print Dumper $csv ; | 271 # print Dumper $csv ; |
272 | 272 |
273 foreach my $line (@{$csv}) { | 273 foreach my $line (@{$csv}) { |
274 | 274 ## HMDB csv output - [DEPRECATED]... |
275 if ($line !~ /query_mass,compound_id,formula,compound_mass,adduct,adduct_type,adduct_mass,delta/) { | 275 # if ($line !~ /query_mass,compound_id,formula,compound_mass,adduct,adduct_type,adduct_mass,delta/) { |
276 my @entry = split(/,/, $line) ; | 276 # my @entry = split(/,/, $line) ; |
277 # | |
278 # if ( !exists $result_by_entry{$entry[0]} ) { $result_by_entry{$entry[0]} = [] ; } | |
279 # | |
280 # $features{ENTRY_ENTRY_ID} = $entry[1] ; | |
281 # $features{ENTRY_FORMULA} = $entry[2] ; | |
282 # $features{ENTRY_CPD_MZ} = $entry[3] ; | |
283 # $features{ENTRY_ADDUCT} = $entry[4] ; | |
284 # $features{ENTRY_ADDUCT_TYPE} = $entry[5] ; | |
285 # $features{ENTRY_ADDUCT_MZ} = $entry[6] ; | |
286 # $features{ENTRY_DELTA} = $entry[7] ; | |
287 # | |
288 # my %temp = %features ; | |
289 # | |
290 # push (@{$result_by_entry{$entry[0]} }, \%temp) ; | |
291 # } | |
292 ## NEW HMDB format V4.0 - dec2017 | |
293 if ($line !~ /query_mass,compound_id,compound_name,kegg_id,formula,monoisotopic_mass,adduct,adduct_type,adduct_m\/z,delta\(ppm\)/) { | |
277 | 294 |
278 if ( !exists $result_by_entry{$entry[0]} ) { $result_by_entry{$entry[0]} = [] ; } | 295 if ( $line =~ /(\d+\.\d+),(\w+),(.*),([\w|n\/a]+)\s*,(\w+),(\d+\.\d+),(.*),(\+|\-),(\d+\.\d+),(\d+)/ ) { |
279 | 296 my @entry = ("$1","$2","$3","$4","$5","$6","$7","$8","$9","$10") ; |
280 $features{ENTRY_ENTRY_ID} = $entry[1] ; | 297 |
281 $features{ENTRY_FORMULA} = $entry[2] ; | 298 if ( !exists $result_by_entry{$entry[0]} ) { $result_by_entry{$entry[0]} = [] ; } |
282 $features{ENTRY_CPD_MZ} = $entry[3] ; | 299 |
283 $features{ENTRY_ADDUCT} = $entry[4] ; | 300 $features{ENTRY_ENTRY_ID} = $entry[1] ; |
284 $features{ENTRY_ADDUCT_TYPE} = $entry[5] ; | 301 $features{ENTRY_FORMULA} = $entry[4] ; |
285 $features{ENTRY_ADDUCT_MZ} = $entry[6] ; | 302 $features{ENTRY_CPD_MZ} = $entry[5] ; |
286 $features{ENTRY_DELTA} = $entry[7] ; | 303 $features{ENTRY_ADDUCT} = $entry[6] ; |
287 | 304 $features{ENTRY_ADDUCT_TYPE} = $entry[7] ; |
288 my %temp = %features ; | 305 $features{ENTRY_ADDUCT_MZ} = $entry[8] ; |
289 | 306 $features{ENTRY_DELTA} = $entry[9] ; |
290 push (@{$result_by_entry{$entry[0]} }, \%temp) ; | 307 |
308 my %temp = %features ; | |
309 push (@{$result_by_entry{$entry[0]} }, \%temp) ; | |
310 } | |
311 else { | |
312 warn "The parsed line ($line) does not match your pattern\n " ; | |
313 } | |
291 } | 314 } |
292 else { | 315 else { |
293 next ; | 316 next ; |
294 } | 317 } |
295 } ## end foreach | 318 } ## end foreach |