[Biojava-l] SeqIOTools.readSwissprot API
Fard, Payam (NIH/NCI)
fardpa at mail.nih.gov
Fri Aug 6 11:36:48 EDT 2004
Hi all,
I am using the following program to read a swissProt file, but I am getting
"Could not read sequence exception". I am using jdk 1.4.2_04-b05 and bioJava
1.4pre1. Any ideas what I am doing wrong?
import org.biojava.bio.seq.*;
import org.biojava.bio.seq.io.*;
import java.io.*;
import org.biojava.bio.*;
import java.util.*;
public class ReadSwiss {
public static void main(String[] args) {
BufferedReader br = null;
try {
//create a buffered reader to read the sequence file specified by
args[0]
br = new BufferedReader(new FileReader(args[0]));
}
catch (FileNotFoundException ex) {
//can't find the file specified by args[0]
ex.printStackTrace();
System.exit(-1);
}
//read the SwissProt File
SequenceIterator sequences = SeqIOTools.readSwissprot(br);
//iterate through the sequences
while(sequences.hasNext()){
try {
Sequence seq = sequences.nextSequence();
//do stuff with the sequence
System.out.println("Sequence length is : " + seq.length());
System.out.println("Sequence name is : " + seq.getName());
}
catch (BioException ex) {
//not in SwissProt format
ex.printStackTrace();
}catch (NoSuchElementException ex) {
//request for more sequence when there isn't any
ex.printStackTrace();
}
}
}
}
I am getting the following exception:
[java] org.biojava.bio.BioException: Could not read sequence
[java] at
org.biojava.bio.seq.io.StreamReader.nextSequence(StreamReader
.java:104)
[java] at ReadSwiss.main(ReadSwiss.java:30)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
[java] at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
sorImpl.java:39)
[java] at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
hodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:324)
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.jav
a:208)
[java] at
org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava
.java:150)
[java] at org.apache.tools.ant.taskdefs.Java.run(Java.java:443)
[java] at
org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:163)
[java] at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
[java] at org.apache.tools.ant.Task.perform(Task.java:341)
[java] at org.apache.tools.ant.Target.execute(Target.java:309)
[java] at org.apache.tools.ant.Target.performTasks(Target.java:336)
[java] at
org.apache.tools.ant.Project.executeTarget(Project.java:1339)
[java] at
org.apache.tools.ant.Project.executeTargets(Project.java:1255
)
[java] at org.apache.tools.ant.Main.runBuild(Main.java:609)
[java] at org.apache.tools.ant.Main.start(Main.java:196)
[java] at org.apache.tools.ant.Main.main(Main.java:235)
[java] Caused by: java.io.IOException: Premature end of stream or
missing e
nd tag '//' for EMBL
[java] at
org.biojava.bio.seq.io.EmblLikeFormat.readSequence(EmblLikeFo
rmat.java:267)
[java] at
org.biojava.bio.seq.io.StreamReader.nextSequence(StreamReader
.java:101)
Thanks,
Payam.
More information about the Biojava-l
mailing list