[Biojava-dev] protein_sequence_alignment

simpleyrx simpleyrx at 163.com
Tue Dec 18 09:32:36 UTC 2007


 
 
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 ?

 



More information about the biojava-dev mailing list