Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
This code should work but you will need to install BioPerl module Bio::SeqIO.
use Bio::SeqIO; # Setting minimum length to 250 my $min_len = 250; # Reading the input fasta file my $seqio_in = Bio::SeqIO->new(-file => "Genes.fasta", -format => "fasta" ); # Creating the output fasta file my $seqio_out = Bio::SeqIO->new(-file => ">Genes_filt_250.fasta", -format => "fasta" ); # Saving sequences to the output if length > min_len while ( my $seq = $seqio_in->next_seq ) { if ( $seq->length > $min_len ) { $seqio_out->write_seq($seq); } }
The sequences with length higher than 250 should be saved in file "Genes_filt_250.fasta":
>NM_030643.4 Homo sapiens apolipoprotein L4 (APOL4) GAGGTGCTGGGGAGCAGCGTGTTTGCTGTGCTTGATTGTGAGCTGCTGGGAAGTTGTGAC TTTCATTTTACCTTTCGAATTCCTGGGTATATCTTGGGGGCTGGAGGACGTGTCTGGTTA TTATATAGGTGCACAGCTGGAGGTGAGATCCACACAGCTCAGACCAGCTGGATCTTGCTC AGTCTCTGTCAGAGGAAGATCCCTTGGAGGAGGCCCCGCAGCGACATGGAGGGAGCTGCT TTGCTGAAAATCTTTGTCGTCTGCATCTGGAACCAAAATC >AC067940.1 Homo sapiens clone RP11-818E9, LOW-PASS SEQUENCE SAMPLING AAATACAACTTTAAATCAAAACGGTAAAAATTCCACTCTTTCATACTAACTTCAAAAGTA TTTGCTTTAAAAAAAAAGNNNNNNNNNNAAACTGAATTTCTATTAAGCATCTATTTATAG AAGAGAGTAAACACCCCGTGAATAAAAGACAGAGAATTGTAGCAGCCCGAAGTCCCTTTT CTCTCCTCCCAAGCATTTGGCTCTGGTCCAAATTCACATATCCTGCTCCGTAAAACAAAG TGCCTTGGTTAACCTAACGTTATTCCTTGAACAGTAGTTTAGTGATCAACTAGTTTTTGT TGTTGTTGTTGTTTGAGACAGAGTCTCACTCTGTCGCCCAGGCTGGAGTGCAGTGGCGAG ATCTCAGCTCACTGCAACCTCTGCTGCCCAGGTTCAAGGGATTCTCCTGCCTCAGCCTCC CAAGTAGCTGGTATTACAGGCACCTGCCACCGCGCCTGGCTAATTTTTTTTTTTTTTTTT TTTTGTATTT

In reply to Re^5: Size of sequences in fastafile by zubenel0
in thread Size of sequences in fastafile by Sofie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-24 00:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found