in reply to retrieving in the correct order
the scanning perl program gen.pl: --------------------------------- #!/usr/bin/perl use strict; my @array = qw(13470319 13470331 15460001 13490216); my @array2; while(my $line = <> ) { foreach my $id (0..$#array) { $array2[$id]=$line if $line =~ m/^gi\|($array[$id])\|/; } } print "order: ", join (" ", @array), "\n"; map {print} @array2; ------------------------------- the text file: gi|13470331|ref|NP_101896.1| hypothetical protein MFWVTKKALMPFLMLPAGIIFVSAVGYAINWLFSTLFQFQPPLVEGPAGPVTVLIFTITMLLAYDISYYL gi|13470319|ref|NP_101897.1| hypothetical protein MGAYCQAHPACKVTDRTVIGRRDAAMNAPFVLAIPRTRTFEVVTSAARLAEIAPAWTALWQRAGGLVFQH ------------------------------- the execution: # cat gen.txt | perl gen.pl order: 13470319 13470331 15460001 13490216 gi|13470319|ref|NP_101897.1| hypothetical protein gi|13470331|ref|NP_101896.1| hypothetical protein
this just looked like a quick and keep it simple job to me..
UPDATE: updated the code to display correct order..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: retrieving in the correct order
by Animator (Hermit) on Dec 16, 2004 at 21:02 UTC | |
by insaniac (Friar) on Dec 16, 2004 at 21:12 UTC |