[Biojava-dev] protein_sequence_alignment

Felipe Albrecht felipe.albrecht at gmail.com
Wed Dec 19 17:10:55 UTC 2007


>From http://biojava.org/wiki/BioJava:Cookbook:Alphabets
it is: "PROTEIN" and not "Protein".
In the 20th line, substitute
FiniteAlphabet alphabet = (FiniteAlphabet) AlphabetManager.alphabetForName
("Protein");
to
FiniteAlphabet alphabet = (FiniteAlphabet) AlphabetManager.alphabetForName
("PROTEIN");

Cheers,
Felipe Albrecht

On Dec 18, 2007 7:32 AM, simpleyrx <simpleyrx at 163.com> wrote:

>
>
> Dear sir,
>
>
> package edu.cau.strLab;
> import java.io.File;
> import org.biojava.bio.alignment.NeedlemanWunsch;
> import org.biojava.bio.alignment.SequenceAlignment;
> import org.biojava.bio.alignment.SmithWaterman;
> import org.biojava.bio.alignment.SubstitutionMatrix;
> import org.biojava.bio.seq.ProteinTools;
> import org.biojava.bio.seq.Sequence;
> import org.biojava.bio.symbol.AlphabetManager;
> import org.biojava.bio.symbol.FiniteAlphabet;
>
> public class ProteinAlignment{
>  public static void main(String[] args) {
>  // TODO Auto-generated method stub
>  try {
>        // The alphabet of the sequences. For this example DNA is choosen.
>        FiniteAlphabet alphabet = (FiniteAlphabet)
> AlphabetManager.alphabetForName("Protein");
>        // Read the substitution matrix file.
>        // For this example the matrix NUC.4.4 is good.
>        SubstitutionMatrix matrix = new SubstitutionMatrix(alphabet, new
> File("E:\\bioinformatics_package\\matrices\\BLOSUM62"));
>        // Define the default costs for sequence manipulation for the
> global alignment.
>        SequenceAlignment aligner = new NeedlemanWunsch(
>          0,  // match
>          3, // replace
>          2,      // insert
>          2, // delete
>          1,      // gapExtend
>          matrix  // SubstitutionMatrix
>        );
> //        Sequence query  = DNATools.createDNASequence("AC", "query");
> //        Sequence target = DNATools.createDNASequence("ACkG", "target");
>      Sequence query =  ProteinTools.createProteinSequence("ACK","query");
>     Sequence subject = ProteinTools.createProteinSequence("ACK",
> "subject");
>
>        // Perform an alignment and save the results.
> //        aligner.pairwiseAlignment(
> //          query, // first sequence
> //          target // second one
> //        );
> //        aligner.pairwiseAlignment(query, subject);
>
>        // Print the alignment to the screen
>
>        System.out.println("Global alignment with Needleman-Wunsch:\n" +
> aligner.getAlignmentString());
>
>        // Perform a local alginment from the sequences with
> Smith-Waterman.
>        // Firstly, define the expenses (penalties) for every single
> operation.
> //        aligner = new SmithWaterman(
> //          -1,     // match
> //          3,      // replace
> //          2,      // insert
> //          2,      // delete
> //          1,      // gapExtend
> //          matrix  // SubstitutionMatrix
> //        );
> //        // Perform the local alignment.
> //        aligner.pairwiseAlignment(query, target);
> //
> //        System.out.println("\nlocal alignment with SmithWaterman:\n" +
> aligner.getAlignmentString());
>      } catch (Exception exc) {
>        exc.printStackTrace();
>      }
>  }
> }
>
>
> the result is below:
>
>
>
> java.util.NoSuchElementException: No alphabet for name Protein could be
> found
>  at org.biojava.bio.symbol.AlphabetManager.alphabetForName(
> AlphabetManager.java:248)
>  at edu.cau.strLab.ProteinAlignment.main(ProteinAlignment.java:20)
>
>
>
> could sb tell why and how to use NeedlemanWunsch to align protein
> sequences ?
>
>
>
> _______________________________________________
> biojava-dev mailing list
> biojava-dev at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/biojava-dev
>
>



More information about the biojava-dev mailing list