Question: How To Display Amino Acid Ailgnment In Biojava Using Biojava
gravatar for joey0214.zhong
7.5 years ago by
joey0214.zhong20 wrote:

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 • 2.8k views
ADD COMMENTlink modified 5.6 years ago by Biostar ♦♦ 20 • written 7.5 years ago by joey0214.zhong20
gravatar for andreas.prlic
7.5 years ago by
San Diego
andreas.prlic290 wrote:

I would do this:

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;

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;

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

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


        } catch (Exception e){

    private static ProteinSequence getSequenceForId(String uniProtId) throws Exception {
        URL uniprotFasta = new URL(String.format("", 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 COMMENTlink modified 7.5 years ago • written 7.5 years ago by andreas.prlic290

thanks for your help~ already fixed it

ADD REPLYlink written 7.4 years ago by joey0214.zhong20
gravatar for AsoInfo
7.5 years ago by
Bonn, Germany
AsoInfo300 wrote:

Maybe this page can help you...

ADD COMMENTlink written 7.5 years ago by AsoInfo300

thanks! I already have alignment.

ADD REPLYlink written 7.5 years ago by joey0214.zhong20
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 634 users visited in the last hour