[Biojava-l] Pairwise alignment of protein sequences

David Zhao wzhao6898 at gmail.com
Thu Jul 9 17:16:37 UTC 2009


Hi there,

I'm new to biojava, and trying to generate a pairwise alignment of 2 protein 
sequences following the example here 
(http://www.biojava.org/wiki/BioJava:CookBook:DP:PairWise2). However, I got:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
	at java.lang.String.charAt(Unknown Source)
	at 
org.biojava.bio.alignment.SubstitutionMatrix.parseMatrix(SubstitutionMatrix.java
:304)
	at 
org.biojava.bio.alignment.SubstitutionMatrix.<init>(SubstitutionMatrix.java:100)
	at 
com.activx.lims.util.ms.tests.TargetListGenerationUtilsTest.testBioJava(TargetLi
stGenerationUtilsTest.java:94)
...
error, and here is my code:
import ...

FiniteAlphabet alphabet = (FiniteAlphabet) 
AlphabetManager.alphabetForName("PROTEIN");
File matrixFile = new File(FULL_PATH_NUC44);
SubstitutionMatrix matrix = new SubstitutionMatrix(alphabet,matrixFile);
SequenceAlignment aligner = new NeedlemanWunsch(new Short("0"),new 
Short("3"),new Short("2"),new Short("2"),new Short("1") ,matrix);
Sequence query = 
ProteinTools.createProteinSequence(PeptidePeer.retrieveByPK(10126404).getSequenc
e(), "query");
Sequence target = 
ProteinTools.createProteinSequence(PeptidePeer.retrieveByPK(10109235).getSequenc
e(), "target");

		      // Perform an alignment and save the results.
		      aligner.pairwiseAlignment(
		        query, // first sequence
		        target // second one
		      );
		      // Print the alignment to the screen
		      System.out.println("Global alignment with Needleman-
Wunsch:\n" + aligner.getAlignmentString());	  

Thanks in advance for any help!

David





More information about the Biojava-l mailing list