Hey guys,
I'm making a simple script that outputs the lineage of a given organism,
For example,
$perl lineage.pl homo sapiens
should output:
$cellular organisms; Eukaryota; Opisthokonta; Metazoa; Eumetazoa; Bilateria; Deuterostomia; Chordata; Craniata; Vertebrata; Gnathostomata; Teleostomi; Euteleostomi; Sarcopterygii; Dipnotetrapodomorpha; Tetrapoda; Amniota; Mammalia; Theria; Eutheria; Euarchontoglires; Primates; Haplorrhini; Simiiformes; Catarrhini; Hominoidea; Hominidae; Homininae; Homo
The script is:
Everything seem to work fine until the last parse (the commented print output looks fine), but I just can't make it print what's between <Lineage></Lineage>.
The relevant urls are:
I'd really appreciate it if somebody could fix the last parse (I have no clue if the first parse is 'right' although it seems to work).
Thanks
..I plan to add espell check after the esearch but I want to get the damn thing working first
I'm making a simple script that outputs the lineage of a given organism,
For example,
$perl lineage.pl homo sapiens
should output:
$cellular organisms; Eukaryota; Opisthokonta; Metazoa; Eumetazoa; Bilateria; Deuterostomia; Chordata; Craniata; Vertebrata; Gnathostomata; Teleostomi; Euteleostomi; Sarcopterygii; Dipnotetrapodomorpha; Tetrapoda; Amniota; Mammalia; Theria; Eutheria; Euarchontoglires; Primates; Haplorrhini; Simiiformes; Catarrhini; Hominoidea; Hominidae; Homininae; Homo
The script is:
Code:
use LWP::Simple; $query = "$ARGV[0]+$ARGV[1]"; #assemble the esearch URL $base = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/'; $url = $base . "esearch.fcgi?db=taxonomy&term=$query"; #post the esearch URL $output = get($url); #parse txid $txid = "$1" if ($output =~ /<Id>(\S+)<\/Id>/); #assemble the efetch URL $url = $base . "efetch.fcgi?db=taxonomy&id=$txid"; #post the esearch URL $output = get($url); #print "$output"; works till here #parse lineage $placement = "$1" if ($output =~ /<Lineage>(\S+)<\/Lineage>/); print $placement;
The relevant urls are:
I'd really appreciate it if somebody could fix the last parse (I have no clue if the first parse is 'right' although it seems to work).
Thanks
..I plan to add espell check after the esearch but I want to get the damn thing working first
Comment