Question: How To Display Amino Acid Ailgnment In Biojava Using Biojava
0
gravatar for joey0214.zhong
6.8 years ago by
Canada
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.6k views
ADD COMMENTlink modified 4.9 years ago by Biostar ♦♦ 20 • written 6.8 years ago by joey0214.zhong20
3
gravatar for andreas.prlic
6.8 years ago by
andreas.prlic290
San Diego
andreas.prlic290 wrote:

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 COMMENTlink modified 6.8 years ago • written 6.8 years ago by andreas.prlic290

thanks for your help~ already fixed it

ADD REPLYlink written 6.7 years ago by joey0214.zhong20
0
gravatar for AsoInfo
6.8 years ago by
AsoInfo250
Bonn, Germany
AsoInfo250 wrote:

Maybe this page can help you...

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

ADD COMMENTlink written 6.8 years ago by AsoInfo250

thanks! I already have alignment.

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

Help
Access

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