[Biojava-l] Swissprot parsing

Matthew Pocock matthew_pocock@yahoo.co.uk
Sun, 13 Oct 2002 15:57:24 +0100

Hi satya,

You are 90% of the way there with your script. You are missing the line:

System.out.println("Sequence: " + sequence.asString());

The sequence itself is stored seperately from the annotations. This lets 
us be careful about memory management. You can access the actual 
nucleotides using the SymbolList API that Sequence inherits from. The 
methods you will probably use are: symbolAt(), asString() and subString().

As for writing this back out as fasta, you can just call:

SeqIOTools.biojavaToFile(SeqIOTools.FASTA, outputStream, sequence);

This will (hopefully) write your sequence to outputStream in the FASTA 
format. Failing that, there is a SeqIOTools.writeFasta() method.


This is a link to the demo that converts a single swissprot file into a 
gff and fasta file. It exposes more of the innards of file parsing, but 
should give you an idea how to proceede.


satyanarayana pasupuleti wrote:
> Hello all:
> I am trying to extract information from a Swissprot file using the below 
> code.
> SequenceIterator seqIter = SeqIOTools.readSwissprot(br);
> while (seqIter.hasNext()) {
>  Sequence sequence = seqIter.nextSequence();
>  Annotation seqAn = sequence.getAnnotation();
>  Set set = seqAn.keys();
>  Iterator iter = set.iterator();
>  while (iter.hasNext()) {
>   String key = (String) iter.next();
>   Object value = seqAn.getProperty (key);
>   System.out.println ("Key: " + key + "\nValue: " + value.toString());
>  }
> }
> However I could not get the sequence data (followed by the line code 
> 'SQ'). Is there any way I can get it?
> Also are there any classes in Bio-Java that Converts one file format to 
> another ... say Swissprot to Fasta?
> Thanks a lot
> -satya
> _________________________________________________________________
> Chat with friends online, try MSN Messenger: http://messenger.msn.com
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l@biojava.org
> http://biojava.org/mailman/listinfo/biojava-l

BioJava Consulting LTD - Support and training for BioJava

Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts