Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
For example, I want to calculate the number of A's in each record. I thought maybe the input record seperator may help, but i'm not sure how to use it. I have written a piece of code but am not sure how to treat each record individually. Sorry for such a low-level question.>gb|AE008687|:70-1377, Atu5000 ATGTCTGGACGTAAAGCGAGAATCATGTTGTATCTTTGGCGGGCTTTGGGCGGCAAACCGAACCTTGCCC +GCCAAGGGGGCGATATGGCGATAGCGAAGCAGATTGAAGCAACGATCGGTCAAAAGGAAGATGCAGGTG +G >gb|AE008687|:1374-2405, Atu5001 ATGACCAGTAAGTCATCGCGTAAATCCATCGTTGCAAATTTCGGACTGCTGTCGGCGGAGCTTGAAAACC
AMmy $in_sequence = 0; my @gene; my $dna; while (<INFILE>) { my $line = $_; if ($line =~ /^>/) { # print $line; $in_sequence = 1; } elsif ($in_sequence) { $dna .= $line; } } print $dna;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: input record separator help
by nite_man (Deacon) on Mar 15, 2004 at 13:52 UTC | |
by Anonymous Monk on Mar 15, 2004 at 14:29 UTC | |
by Limbic~Region (Chancellor) on Mar 15, 2004 at 14:53 UTC | |
by Anonymous Monk on Mar 15, 2004 at 15:00 UTC | |
by Limbic~Region (Chancellor) on Mar 15, 2004 at 15:11 UTC | |
|
Re: input record separator help
by Limbic~Region (Chancellor) on Mar 15, 2004 at 13:47 UTC | |
|
Re: input record separator help
by helgi (Hermit) on Mar 15, 2004 at 14:49 UTC | |
|
Re: input record separator help
by tinita (Parson) on Mar 15, 2004 at 13:58 UTC | |
|
Re: input record separator help
by Happy-the-monk (Canon) on Mar 15, 2004 at 14:36 UTC |