[Biojava-dev] insufficient memory

mark.schreiber at group.novartis.com mark.schreiber at group.novartis.com
Wed Feb 2 21:00:53 EST 2005


Try increasing your stack (heap?) size using the -Xmx option on the 
command line. Or, take a look at 
http://www.biojava.org/docs/bj_in_anger/blastecho.htm





"badr al-daihani" <aldaihani at hotmail.co.uk>
Sent by: biojava-dev-bounces at portal.open-bio.org
02/03/2005 09:53 AM

 
        To:     biojava-dev at biojava.org
        cc:     (bcc: Mark Schreiber/GP/Novartis)
        Subject:        [Biojava-dev] insufficient memory



hi folks

I use BlastParser to parse a big file (hundreds of mega) but I get 
insufficient memory error
any idea to overcome this problem.

best regards


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] is assumed to be the name of a Blast output file
   */
  public static void main(String[] args) {
    try {
      //get the Blast input as a Stream
      InputStream is = new FileInputStream(args[0]);

      //make a BlastLikeSAXParser
      BlastLikeSAXParser parser = new BlastLikeSAXParser();

      //make the SAX event adapter that will pass events to a Handler.
      SeqSimilarityAdapter adapter = new SeqSimilarityAdapter();

      //set the parsers SAX event adapter
      parser.setContentHandler(adapter);

      //The list to hold the SeqSimilaritySearchResults
      List results = new ArrayList();

      //create the SearchContentHandler that will build 
SeqSimilaritySearchResults
      //in the results List
      SearchContentHandler builder = new BlastLikeSearchBuilder(results,
          new DummySequenceDB("queries"), new 
DummySequenceDBInstallation());

      //register builder with adapter
      adapter.setSearchContentHandler(builder);

      //parse the file, after this the result List will be populated with
      //SeqSimilaritySearchResults
      parser.parse(new InputSource(is));

      //output some blast details
      for (Iterator i = results.iterator(); i.hasNext(); ) {
        SeqSimilaritySearchResult result =
            (SeqSimilaritySearchResult)i.next();

        Annotation anno = result.getAnnotation();

        for (Iterator j = anno.keys().iterator(); j.hasNext(); ) {
          Object key = j.next();
          Object property = anno.getProperty(key);
          System.out.println(key+" : "+property);
        }
        System.out.println("Hits: ");

        //list the hits
        for (Iterator k = result.getHits().iterator(); k.hasNext(); ) {
          SeqSimilaritySearchHit hit =
              (SeqSimilaritySearchHit)k.next();
          System.out.print("\tmatch: "+hit.getSubjectID());
          System.out.println("\te score: "+hit.getEValue());
        }

        System.out.println("\n");
      }

    }
    catch (SAXException ex) {
      //XML problem
      ex.printStackTrace();
    }catch (IOException ex) {
      //IO problem, possibly file not found
      ex.printStackTrace();
    }
  }
}

_________________________________________________________________
It's fast, it's easy and it's free. Get MSN Messenger today! 
http://www.msn.co.uk/messenger

_______________________________________________
biojava-dev mailing list
biojava-dev at biojava.org
http://biojava.org/mailman/listinfo/biojava-dev





More information about the biojava-dev mailing list