[Biojava-l] sort fasta file

xyz mitlox at op.pl
Sat Mar 20 10:17:17 UTC 2010


Hello,
I would like to sort multiple fasta file depends on the sequence length,
ie. from the read with longest sequence to the read with the shortest
sequence.

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import org.biojava.bio.BioException;

import org.biojavax.SimpleNamespace;
import org.biojavax.bio.seq.RichSequence;
import org.biojavax.bio.seq.RichSequenceIterator;

public class SortFasta {

  public static void main(String[] args) throws FileNotFoundException,
  BioException {

    BufferedReader br = new BufferedReader(new
    FileReader("sortfasta.fasta")); SimpleNamespace ns = new
    SimpleNamespace("biojava");

    RichSequenceIterator rsi = RichSequence.IOTools.readFasta(br, null,
    ns);

    while (rsi.hasNext()) {
      RichSequence rs = rsi.nextRichSequence();
      System.out.println(rs.getName());
      System.out.println(rs.seqString());
    }
  }
}

I have tried to do it, but I do not how to continue.

Thank you in advance.

Best regards,



More information about the Biojava-l mailing list