MonkPaul has asked for the wisdom of the Perl Monks concerning the following question:
I have a question - Can i use a second regex when looking through a line in a file.
For instance i am currently looking for Homo sapien in one line of a file, but i also want to look for chromosome 11 say. At the moment, i am saving the filtered data from Homo sapiens search into an array, then conducting the search on this to find the chromosome 11.
for (my $i = 0 ; $i<scalar @line; $i++) { if ($line[$i] =~ /^>/) { $current_subject = $line[$i]; chomp ($current_subject); push (@filtered_subjects, $current_subject); } } my @element;
So stored in the array is:
>gi|14670349|ref|NM_032999.1| Homo sapiens general transcription facto +r II, i (GTF2I), transcript >gi|2827179|gb|AF035737.1|AF035737 Homo sapiens general transcription +factor 2-I (GTF2I) mRNA, complete >gi|19908489|gb|AF343351.1| Mus musculus TFII-I repeat domain-containi +ng protein 3 beta 7 mRNA,
Is this the best way to do it, or can i use something like:foreach my $z (@filtered_subjects) { chomp $z; @element = split('\|', $z); if($element[4] =~ /\Q$Homosapiens\E/) { push(@chromoLine, $z); } } }
if($element[4] =~ /\Q$Homosapiens$choromosome\E/)
Any help is appreciated.
thanks,
MonkPaul.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Double RegEx
by ikegami (Patriarch) on Jun 27, 2005 at 14:38 UTC | |
by MonkPaul (Friar) on Jun 27, 2005 at 14:44 UTC | |
by MonkPaul (Friar) on Jun 29, 2005 at 13:27 UTC | |
by ikegami (Patriarch) on Jun 29, 2005 at 14:42 UTC | |
|
Re: Double RegEx
by rev_1318 (Chaplain) on Jun 27, 2005 at 14:38 UTC |