This is a test version of Biostars. For the public version, visit https://www.biostars.org.
CookbookMSA Multiple Sequence Alignement error in biojava demo

Hello I'm trying to run the Multiple Sequence Alignment using biojava and ready code recommended by biojava

public class CookbookMSA {

    public static void main(String[] args) {
        String[] ids = new String[] {"Q21691", "Q21495", "O48771"};
        try {
            multipleSequenceAlignment(ids);
        } catch (Exception e){
            e.printStackTrace();
        }
    }

    private static void multipleSequenceAlignment(String[] ids) throws Exception {
        List<ProteinSequence> lst = new ArrayList<ProteinSequence>();
        for (String id : ids) {
            lst.add(getSequenceForId(id));
        }
        Profile<ProteinSequence, AminoAcidCompound> profile = Alignments.getMultipleSequenceAlignment(lst);
        System.out.printf("Clustalw:%n%s%n", profile);
        ConcurrencyTools.shutdown();
    }

    private static ProteinSequence getSequenceForId(String uniProtId) throws Exception {
        URL uniprotFasta = new URL(String.format("<a href="http://www.uniprot.org/uniprot/%s.fasta">http://www.uniprot.org/uniprot/%s.fasta</a>", uniProtId));
        ProteinSequence seq = FastaReaderHelper.readFastaProteinSequence(uniprotFasta.openStream()).get(uniProtId);
        System.out.printf("id : %s %s%n%s%n", uniProtId, seq, seq.getOriginalHeader());
        return seq;
    }

}

But I got an error:

id : A3SA23 MKFTFFLMLGTSALALSAGVATAQDAVDLGEIIIQSEEDPTGPVVGYAAGTTASTKSGRSLLETPSSVTVVTTDQIEDTAANNLSEALGYAAGVVTEAYGADPRFDSISVRGADLQNQIYLNGLQFSRSTRPNYGAPSLDLYGMERVELLRGPNSVLYGAGSPAGLVNLIQKRAQSDGDTTELGLHADGNGSHYVFGDANRVVDDRFAYRIVGKAGNRVLGIDEYDNPGAYLGFAAKYQATDATTVEFLLSYQDDDPDSPSGVPNGLVGTRSDEDLRDFYFGNEALEYGDRKVLNLGAQVTHTFDNGWRLVSNTGVTKFDWSYSNLFVGGVTGTDVARTQLLQDEDVTSYATDLRLEGSALTGDVLHNLAFGIDASRFEETALSVFYYGQDSIDFAAPDYSPITPVRDGASWYANKNVTVEQVGIYASDEIEYGNWRAGLALRHDRNKSEGQSNTLYTVPGSGGTPGTVDLTRDDSATTGQASLGYVWDNGVSAYLSYGTSFQSFAEPGDTGTALDPTTGEQWEVGAKYLPATLDAYLSASVYQLEEKNRPVYVQNGAGVRAYDQVGKSRIRGLELEGRANLADGWSVTGGYSYTDSEIIGGDNNGNELGLTPKHTFKLWASKEIQGGPLAGLTVGAGARFIGERYAFNANANQLDSVTLLDAAVSYDFDDGTELQVNVTNLTDEAYVSSVGYFSTYYGDGRTISATLSKKW
tr|A3SA23|A3SA23_9RHOB TonB dependent, hydroxamate-type ferrisiderophore, outer membrane receptor OS=Sulfitobacter sp. EE-36 GN=EE36_08023 PE=3 SV=1
java.lang.ArrayIndexOutOfBoundsException: 0
 at org.biojava3.core.sequence.io.GenericFastaHeaderParser.parseHeader(GenericFastaHeaderParser.java:113)
 at org.biojava3.core.sequence.io.GenericFastaHeaderParser.parseHeader(GenericFastaHeaderParser.java:60)
 at org.biojava3.core.sequence.io.FastaReader.process(FastaReader.java:182)
 at org.biojava3.core.sequence.io.FastaReader.process(FastaReader.java:108)
 at org.biojava3.core.sequence.io.FastaReaderHelper.readFastaProteinSequence(FastaReaderHelper.java:100)
 at CookbookMSA.getSequenceForId(CookbookMSA.java:35)
 at CookbookMSA.multipleSequenceAlignment(CookbookMSA.java:26)
 at CookbookMSA.main(CookbookMSA.java:17)

what does it mean?

I use Windows, and Eclipse Luna

multiple-sequence-alignment biojava

1 answer

One of the UniProt IDs in the example got deleted. http://www.uniprot.org/uniprot/Q21495. Try these UniProt accession codes instead: Q21691 A8WS47 O48771

This is true. But I noticed that problem is with java. I have jre8, I dont know why but biojava works only with jre7

if you get the latest trunk code from github, it works also with Java 8.

Log in to answer this question.