[Biojava-l] Parse a Blast

mark.schreiber at novartis.com mark.schreiber at novartis.com
Sun Jun 12 22:05:58 EDT 2005


Hello -

I suspect the problem is that you are using the BlastLikeSAXParser. This 
was written in the days before blast xml was available (and stable) and is 
an adapter that parses a non-xml blast report and produces SAX events.

The parser you want is org.biojava.bio.program.sax.blastxml.BlastXMLParser

Hope this helps,

- Mark




Sébastien PETIT <great_fred at yahoo.com>
Sent by: biojava-l-bounces at portal.open-bio.org
06/10/2005 10:18 PM

 
        To:     biojava-l at biojava.org
        cc:     (bcc: Mark Schreiber/GP/Novartis)
        Subject:        [Biojava-l] Parse a Blast


Hello

First of all, sorry for my English (I'm French..)
Now, my problem...
I have Blast in XML format. I want to parse it because I want just the
alignment.
But, when I use a script found on the Net, the answer is :
--> org.xml.sax.SAXException: Could not recognise the format of this
file as one supported by the framework.

Does anybody have the same problem?
Or Does anybody have an idea to resolve my problem?

Here is the script (Sorry, the comment are in French..)

   import java.io.*;
   import java.util.*;

   import org.biojava.bio.program.sax.*;
   import org.biojava.bio.program.ssbind.*;
   import org.biojava.bio.search.*;
   import org.biojava.bio.seq.db.*;
   import org.xml.sax.*;
   import org.biojava.bio.*;

    public class BlastParser {
   /**
   * args[0] est assumé être le nom du fichier de sortie BLAST */
       public static void main(String[] args) {
         try {
         //obtenir les entrées Blast sous la forme de Stream
            InputStream is = new FileInputStream(args[0]);
 
         //construire un BlastLikeSAXParser
            BlastLikeSAXParser parser = new BlastLikeSAXParser();
 
         //construire un adaptateur pour SAX event qui les passera a un
Handler.
            SeqSimilarityAdapter adapter = new SeqSimilarityAdapter();
 
         //initialiser l'adaptateur des SAX events  de l'objet parser
            parser.setContentHandler(adapter);
 
         //la liste qui contiendra les SeqSimilaritySearchResults
            List results = new ArrayList();
 
         //créer le SearchContentHandler qui construira les
SeqSimilaritySearchResults
         //dans la liste results
            SearchContentHandler builder = new
BlastLikeSearchBuilder(results,
               new DummySequenceDB("queries"), new
DummySequenceDBInstallation());
 
         //enregistrer builder aupres de adapter
            adapter.setSearchContentHandler(builder);
 
         //parcourir le fichier; après, la liste result contiendra
         //les SeqSimilaritySearchResults
 
            parser.parse(new InputSource(is));
            //formatResults(results);
         }
             catch (SAXException ex) {
            //probleme de XML
               ex.printStackTrace();
            }
             catch (IOException ex) {
            //probleme de IO, comme un fichier introuvable
               ex.printStackTrace();
            }
      }
   }

Thank you for any answer...

Great-Fred


 

 
 
___________________________________________________________________________ 

Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 

Téléchargez cette version sur http://fr.messenger.yahoo.com
_______________________________________________
Biojava-l mailing list  -  Biojava-l at biojava.org
http://biojava.org/mailman/listinfo/biojava-l






More information about the Biojava-l mailing list