This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Smithwaterman alignment related question: need alignment score

How to get the alignment score? This is the code I am using:

DNASequence target = null; try { target = new DNASequence(seq1.toString(), AmbiguityDNACompoundSet.getDNACompoundSet()); } catch (CompoundNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); }

    DNASequence query = null;

    try {
        query = new DNASequence(seq2.toString(), AmbiguityDNACompoundSet.getDNACompoundSet());
    } catch (CompoundNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    SubstitutionMatrix<NucleotideCompound> matrix = SubstitutionMatrixHelper.getNuc4_4();
    SimpleGapPenalty gapP = new SimpleGapPenalty();
    gapP.setOpenPenalty((short)5);
    gapP.setExtensionPenalty((short)2);

    SequencePair<DNASequence, NucleotideCompound> psa =
            Alignments.getPairwiseAlignment(query, target,
                    PairwiseSequenceAlignerType.LOCAL, gapP, matrix);

```

alignment

Is this BioJava? If so, you might want to tag your post with that.

1 answer

take a look!

public class DeterministicAlignmentDemo {
    public static void main(String[] args) throws Exception{
        String targetSeq = "AGGCCTGGCTCTGAAGAGGACCAAATGAGAGCCCCTTACTTATTTCA";
        DNASequence target = new DNASequence(targetSeq,AmbiguityDNACompoundSet.getDNACompoundSet());


        String querySeq = "yyray";
        DNASequence query = new DNASequence(querySeq,AmbiguityDNACompoundSet.getDNACompoundSet());


        SubstitutionMatrix<NucleotideCompound> matrix = SubstitutionMatrixHelper.getNuc4_4();

        SimpleGapPenalty gapP = new SimpleGapPenalty();
        gapP.setOpenPenalty((short)5);
        gapP.setExtensionPenalty((short)2);

        SequencePair<DNASequence, NucleotideCompound> psa =
                Alignments.getPairwiseAlignment(query, target,PairwiseSequenceAlignerType.LOCAL, gapP, matrix);
        System.out.println(psa);
        System.out.println(psa.getIndexInTargetAt(1));
        System.out.println(psa.getIndexInQueryAt(1));
        System.out.println(Alignments.getPairwiseAligner(query, target, PairwiseSequenceAlignerType.LOCAL,gapP, matrix).getMaxScore());
    }
}

Log in to answer this question.