[Biojava-l] beginners bug fileToBiojava problem with msf format

VERHOEF Frans verhoeff2 at gis.a-star.edu.sg
Thu Feb 5 02:34:18 EST 2004


> Hello, I am a new user to biojava (and almost new to java).
> 
> The following code works fine reading a 'FASTA' format file,
> but causes an error reading 'MSF' format...
> 
> -----
> String file     = args[0];
> String format   = args[1];
> String alphabet = args[2];
> 
> BufferedReader br = new BufferedReader(new FileReader(file));
> 
> SequenceIterator seqi = null;
> Alignment align = null;
> 
> if ( format != "MSF" && format != "msf" ){

Change this line to:
if ( format.toLowerCase().equals("msf") == false ){

Because I wonder whether you ever get in here. For your information, if
you use == or != to compare 2 strings (or other objects) it will not
compare the content but it will only compare whether the 2 objects have
the same address. If you would have assigned format directly with "msf"
(i.e. String format = "str"), then it would have worked, because then
both format and the string "msf" in the if statement are pointing to the
same address. In this case format is assigned an external argument which
happens to have the same value, but is most probably pointing to a
different address. 
I hope it is clear what I try to explain ;-)

>   seqi =
>     (SequenceIterator)SeqIOTools.fileToBiojava( format, alphabet, br
);
> }
> else{
>   align =
>     (Alignment)SeqIOTools.fileToBiojava( format, alphabet, br );
> }
> ----
> 
> Error...
> 
> ---
> Exception in thread "main" java.lang.IllegalArgumentException: No
alphabet
> was set in the identifier
>         at
> org.biojava.bio.seq.io.SeqIOTools.fileToBiojava(SeqIOTools.java:801)
>         at
> org.biojava.bio.seq.io.SeqIOTools.fileToBiojava(SeqIOTools.java:787)
>         at
> ReadAlignMakeDistribution.main(ReadAlignMakeDistribution.java:60)
> ---
> 
> Line 60 corresponds to the "align = ..." line above.
> 
> Like I said, works fine as...
> 
> java prog.java fa.fasta fasta PROTEIN
> 
> but
> 
> java prog.java msf.msf msf PROTEIN
> 
> Gives above error... Just as I thought I was begining to understand
:.(
> 
> I will look at details for Alignment objects...
> 
> 
> _______________________________________________
> Biojava-l mailing list  -  Biojava-l at biojava.org
> http://biojava.org/mailman/listinfo/biojava-l



More information about the Biojava-l mailing list