How To Display Amino Acid Ailgnment In Biojava Using Biojava
2
0
Entering edit mode
11.8 years ago

how to display amino acid ailgnment in biojava using Biojava? I'm using Graphics2D to drew amino acid sequences alignment in my biojava application, but it didn't work! it displayed sequence names , but not render aligned sequences.

biojava alignment • 4.1k views
ADD COMMENT
3
Entering edit mode
11.8 years ago
andreas.prlic ▴ 290

I would do this:

import java.net.URL;
import org.biojava3.alignment.Alignments;
import org.biojava3.alignment.SimpleGapPenalty;
import org.biojava3.alignment.SubstitutionMatrixHelper;
import org.biojava3.alignment.Alignments.PairwiseSequenceAlignerType;
import org.biojava3.alignment.template.GapPenalty;
import org.biojava3.alignment.template.PairwiseSequenceAligner;
import org.biojava3.alignment.template.SequencePair;
import org.biojava3.alignment.template.SubstitutionMatrix;
import org.biojava3.core.sequence.ProteinSequence;
import org.biojava3.core.sequence.compound.AminoAcidCompound;
import org.biojava3.core.sequence.io.FastaReaderHelper;

public class DemoAlignProteins {

    public static void main(String[] args) {

        try {
            String uniprotID1 = "P69905";
            String uniprotID2 = "P68871";

            ProteinSequence s1 = getSequenceForId(uniprotID1);
            ProteinSequence s2 = getSequenceForId(uniprotID2);

            SubstitutionMatrix<AminoAcidCompound> matrix = SubstitutionMatrixHelper.getBlosum65();

            GapPenalty penalty = new SimpleGapPenalty();

            short gop = 8;
            short extend = 1;
            penalty.setOpenPenalty(gop);
            penalty.setExtensionPenalty(extend);


            PairwiseSequenceAligner<ProteinSequence, AminoAcidCompound=""> smithWaterman =
                    Alignments.getPairwiseAligner(s1, s2, PairwiseSequenceAlignerType.LOCAL, penalty, matrix);

            SequencePair<ProteinSequence, AminoAcidCompound=""> pair = smithWaterman.getPair();


            System.out.println(pair.toString(60));

        } catch (Exception e){
            e.printStackTrace();
        }
    }

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

}

ADD COMMENT
0
Entering edit mode

thanks for your help~ already fixed it

ADD REPLY
0
Entering edit mode
11.8 years ago
AsoInfo ▴ 300

Maybe this page can help you...

http://biojava.org/wiki/BioJava:CookBook3:PSA

ADD COMMENT
0
Entering edit mode

thanks! I already have alignment.

ADD REPLY

Login before adding your answer.

Traffic: 1505 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6