当前位置: 首页>>代码示例>>Java>>正文


Java PairwiseSequenceAligner.getPair方法代码示例

本文整理汇总了Java中org.biojava.nbio.alignment.template.PairwiseSequenceAligner.getPair方法的典型用法代码示例。如果您正苦于以下问题:Java PairwiseSequenceAligner.getPair方法的具体用法?Java PairwiseSequenceAligner.getPair怎么用?Java PairwiseSequenceAligner.getPair使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.biojava.nbio.alignment.template.PairwiseSequenceAligner的用法示例。


在下文中一共展示了PairwiseSequenceAligner.getPair方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testComplex

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
@Test
	public void testComplex() throws Exception {

		short match = 2, gop = -5, gep = -3; // 2, 5, and 3 are coprime; -2 is the mismatch score
		SimpleSubstitutionMatrix<NucleotideCompound> mx = new SimpleSubstitutionMatrix<NucleotideCompound>(new DNACompoundSet(), match, (short)-match);

		DNASequence a = new DNASequence("CGTAT  ATATCGCGCGCGCGATATATATATCT TCTCTAAAAAAA".replaceAll(" ", ""));
		DNASequence b = new DNASequence("GGTATATATATCGCGCGCACGAT TATATATCTCTCTCTAAAAAAA".replaceAll(" ", ""));
//                                       --CGTATATATCGCGCGCGCGATATATATATCT-TCTCTAAAAAAA
//                                       GGTATATATATCGCGCGCACGAT-TATATATCTCTCTCTAAAAAAA
//  mismatches:                             ^              ^
// The two alignments should have the same score. The bottom one is the one the aligner found.

		PairwiseSequenceAligner<DNASequence, NucleotideCompound> aligner = Alignments.getPairwiseAligner(a, b, Alignments.PairwiseSequenceAlignerType.GLOBAL, new SimpleGapPenalty(gop, gep), mx);
		SequencePair<DNASequence, NucleotideCompound> pair = aligner.getPair();


		int nMatches = "--CGTATATATCGCGCGCGCGATATATATATCT-TCTCTAAAAAAA".length() - 2 - 4;
		double expectedScore = nMatches * match
									   - 2 * match // there are two mismatches
									   + 3 * gop + 4 * gep; // there are 3 gap opens and either 1 or 4 extensions, depending on the def
		assertEquals(expectedScore, aligner.getScore(), 0.00000001);
	}
 
开发者ID:biojava,项目名称:biojava,代码行数:24,代码来源:NeedlemanWunschTest.java

示例2: align

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
@Nonnull
public SequenceAlignment<S, C> align(@Nonnull S a, @Nonnull S b) {
	PairwiseSequenceAligner<S, C> aligner = Alignments.getPairwiseAligner(a, b, m_type, m_gapPenalty, m_matrix);
	//noinspection ConstantConditions
	if (aligner == null) {
		throw new RuntimeException("Couldn't create aligner; something is wrong in Biojava");
	}
	// this actually performs the alignment; do it first
	SequencePair<S, C> pair = aligner.getPair();
	return new SequenceAlignment<>(toIntExact(aligner.getScore()), aligner.getSimilarity(), pair);
}
 
开发者ID:dmyersturnbull,项目名称:sequence-alignment,代码行数:12,代码来源:SequenceAligner.java

示例3: main

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		String query = "AGGATGAACGCTGGCGGCGTGCTTAACACATGCAAGTCGAACGGTGAAGCCCAGCTTGCTGGGTGGATCA" +
		"GTGGCGAACGGGTGAGTAACACGTGAGCAACCTGCCCCTGACTCTGGGATAAGCGCTGGAAACGGTGTCT" +
		"AATACTGGATATGAGCTACCACCGCATGGTGAGTGGTTGGAAAGATTTTTCGGTTGGGGATGGGCTCGCG" +
		"GCCTATCAGCTTGTTGGTGAGGTAATGGCTCACCAAGGCGTCGACGGGTAGCCGGCCTGAGAGGGTGACC" +
		"GGCCACACTGGGACTGAGACACGGCCCAGACTCTACGGGAGGCAGCAGTGGGGAATATTGCACAATGGGC" +
		"GGAAGCCTGATGCAGCAACGCCGCGTGAGGGACGACGGCTTCGGGTTGTAAACCTCTTTTAGCAGGGAAG" +
		"AAGCGAGAGTGACGGTACCTGCAGAAAAAGCGCCGGCTAACTACGTGCCAGCAGCCGCGGTAATACGTAG" +
		"GGCGCAAGCGTTATCCGGAATTATTGGGCGTAAAGAGCTCGTAGGCGGTTTGTCGCGTCTGCTGTGAAAA" +
		"CCCGAGGCTCAACCTNNGGGCTGCAGTGGGTACGGGCAGACTAGAGTGCGGTAGGGGAGATTGGAATTCC" +
		"TGGTGTAGCGGTGGAATGCGCAGATATCAGGAGGAACACCGATGGCGAAGGCAGATCTCTGGGCCGTAAC" +
		"TGACGCTGAGGAGCGAAAGGGTGGGGAGCAAACAGGCTTAGATACCCTGGTAGTCCACCCCGTAAACGTT" +
		"GGGAACTAGTTGTGGGGTCCTTTCCACGGATTCCGTGACGCACGTAACGCATTAAGTTCCCCGCCTGGGG" +
		"AGTACGGCCGCAAGGCTAAAACTCAAAGGAATTGACGGGGACCCGCACAAGCGGCGGAGCATGCGGATTA" +
		"AATCGATGCAACGCGAAGAACCTTACCAAGGCTTGACATACACGAGAACGCTGCAGAAATGTAGAACTCT" +
		"TTGGACACTCGTGAACAGGTGGTGCATGGTTGTCGTCAGCTCGTGTCGTGAGATGTTGGGTTAAGTCCCG" +
		"CAACGAGCGCAACCCTCGTTCTATGTTGCCAGCACGTAATGGTGGGAACTCATGGGATACTGCCGGGGTC" +
		"AACTCGGAGGAAGGTGGGGATGACGTCAAATCATCATGCCCCTTATGTCTTGGGCTTCACGCATGCTACA" +
		"ATGGCCGGTACAAAGGGCTGCAATACCGTGAGGTGGAGCGAATCCCAAAAAGCCGGTCCCAGTTCGGATT" +
		"GAGGTCTGCAACTCGACCTCATGAAGTCGGAGTCGCTAGTAATCGCAGATCAGCAACGCTGCGGTGAATA" +
		"CGTTCCCGGGTCTTGTACACACCGCCCGTCAAGTCATGAAAGTCGGTAACACCTGAAGCCGGTGGCCTAA" +
		"CCCTTGTGGAGGGAGCCGGTAATTAAA";

		String target = "CTGGCCGCCTGCTTAACACATCCAAGTCGAACGGTGAAGCCCCANCTTACTGGGTGGATCAGTGCCGAAC" +
		"GGGTGAGTAACACGTGAGCAACCTCCCCCTGACTCTGGGATAAGCGCTGGAANCGGTGTCTAATACTGGA" +
		"TATGAGCTACCACCGCATGGTGAGTGGTTGGAAAGATTTTTCGGTTGGGGATGGGCTCGCGCCCTATGAG" +
		"CTTGTTGGTGAGGTAATGGCTCACCAAGCCGTCGACGGGTAGCCGGCCTGAGAGGGTGACCGNCCACACT" +
		"GGGACTGAGACACGGCCCAGACTCCTACGGGAGGCAGCAGTGGGGAATATTGCACAATGGGCGGAAGCCT" +
		"GATTCANCAACCCCGCGTGAGGGACGACGGCCTTCGGGTTGTAAACCTCTTTTAGCAGGGAAGAAGCGAG" +
		"AGTGACGGTACCTGCAGAAAAAGCCCCGGCTAACTACGTGCCAGCAGCCGCGGTAATACGTAGGGCGCAA" +
		"GCGTTATCCGGAATTATTGGGCGTAAAGAGCTCGTAGGCGGTTTGTCGCGTCTGCTGTGAAAACCCGAGG" +
		"CTCAACCTCGGGCCTGCAGTGGGTACGGGCAGACTAGAGTGCGGTAGGGGAGATTGGAATTCCTGGTGTA" +
		"GCGGTGGAATGCGCAGATATCAGGAGGAACACCGATGGCGAAGGCAGATCTCTGGGCCGTAACTGACGCT" +
		"GAGGAGCGAAAGGGTGGGGAGCAAACAGGCTTAGATACCCTGGTAGTCCACCCCGTAAACGTTGGGAACT" +
		"AGTTGTGGGGTCCTTTCCACGGATTCCGTGACGCAGCTAACGCATTAAGTTCCCCGCCTGGGGAGTACGG" +
		"CCGCAAGGCTAAAACTCAAAGGAATTGACGGGGACCCGCACAAGCGGCGGAGCATGCGGATTAATTCGAT" +
		"GCAACGCGAAGAACCTTACCAAGGCTTGACATACACGAGAACGCTGCAGAAATGTAGAACTCTTTGGACA" +
		"CTCGTGAACAGGTGGTGCATGGTTGTCGTCAGCTCGTGTCGTGAGATGTTGGGTTAAGTCCCGCAACGAG" +
		"CGCAACCCTCGTTCTATGTTGCCAGCACGTAATGGTGGGAACTCATGGGATACTGCCGGGGTCAACTCGG" +
		"AGGAAGGTGGGGATGACGTCAAATCATCATGCCCCTTATGTCTTGGGCTTCACGCATGCTACAATGGCCG" +
		"GTACAAAGGGCTGCAATACCGTGAGGTGGAGCGAATCCCAAAAAGCCGGTCCCAGTTCGGATTGAGGTCT" +
		"GCAACTCGACCTCATGAAGTCGGAGTCGCTAGTAATCGCAGATCAGCAACGCTGCGGTGAATACGTTCCC" +
		"GGGTCTTGTACACACCGCCCGTCAAGTCATGAAAGTCGGTAACACCTGAAGCCGGTGGCCCAACCCTTGT" +
		"GGAGGGAGCCGTCGAAGGTGGGATCGGTAATTAGGACTAAGTCGTAACAAGGTAGCCGTACC";

		GapPenalty penalty = new SimpleGapPenalty(-14, -4);
		PairwiseSequenceAligner<DNASequence, NucleotideCompound> aligner = Alignments.getPairwiseAligner(
				new DNASequence(query, AmbiguityDNACompoundSet.getDNACompoundSet()),
				new DNASequence(target, AmbiguityDNACompoundSet.getDNACompoundSet()),
				PairwiseSequenceAlignerType.GLOBAL,
				penalty, SubstitutionMatrixHelper.getNuc4_4());
		SequencePair<DNASequence, NucleotideCompound>
		alignment = aligner.getPair();

		System.out.println("Alignment: "+ alignment);

		int identical = alignment.getNumIdenticals();
		System.out.println("Number of identical residues: "+ identical);
		System.out.println("% identical query: "+ identical / (float) query.length());
		System.out.println("% identical target: "+ identical / (float) target.length());
	}
 
开发者ID:biojava,项目名称:biojava,代码行数:63,代码来源:TestDNANeedlemanWunsch.java

示例4: alignProtein

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
private static SequencePair<ProteinSequence, AminoAcidCompound> alignProtein(ProteinSequence s1, ProteinSequence s2) {
	SubstitutionMatrix<AminoAcidCompound> matrix = SubstitutionMatrixHelper.getIdentity();

	GapPenalty penalty = new SimpleGapPenalty(8, 1);

	PairwiseSequenceAligner<ProteinSequence, AminoAcidCompound> nw =
			Alignments.getPairwiseAligner(s1, s2, PairwiseSequenceAlignerType.GLOBAL, penalty, matrix);

	return nw.getPair();
}
 
开发者ID:biojava,项目名称:biojava,代码行数:11,代码来源:EntityFinder.java

示例5: alignDNA

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
private static SequencePair<DNASequence, NucleotideCompound> alignDNA(DNASequence s1, DNASequence s2) {
	SubstitutionMatrix<NucleotideCompound> matrix = SubstitutionMatrixHelper.getNuc4_4();

	GapPenalty penalty = new SimpleGapPenalty(8, 1);

	PairwiseSequenceAligner<DNASequence, NucleotideCompound> nw =
			Alignments.getPairwiseAligner(s1, s2, PairwiseSequenceAlignerType.GLOBAL, penalty, matrix);

	return nw.getPair();
}
 
开发者ID:biojava,项目名称:biojava,代码行数:11,代码来源:EntityFinder.java

示例6: alignRNA

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
private static SequencePair<RNASequence, NucleotideCompound> alignRNA(RNASequence s1, RNASequence s2) {
	SubstitutionMatrix<NucleotideCompound> matrix = SubstitutionMatrixHelper.getNuc4_4();

	GapPenalty penalty = new SimpleGapPenalty(8, 1);

	PairwiseSequenceAligner<RNASequence, NucleotideCompound> nw =
			Alignments.getPairwiseAligner(s1, s2, PairwiseSequenceAlignerType.GLOBAL, penalty, matrix);

	return nw.getPair();
}
 
开发者ID:biojava,项目名称:biojava,代码行数:11,代码来源:EntityFinder.java

示例7: main

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		String uniprotID1 = "P69905";
		String uniprotID2 = "P68871";

		ProteinSequence s1 = getSequenceForId(uniprotID1);
		ProteinSequence s2 = getSequenceForId(uniprotID2);

		SubstitutionMatrix<AminoAcidCompound> matrix = SubstitutionMatrixHelper.getBlosum65();

		GapPenalty penalty = new SimpleGapPenalty();

		int gop = 8;
		int 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));


	}
 
开发者ID:biojava,项目名称:biojava,代码行数:29,代码来源:DemoAlignProteins.java

示例8: call

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
@Override
public Tuple5<String,String,Float,Float,Float> call(Tuple2<Tuple2<String,String>,Tuple2<String,String>> tuple) throws Exception {

    Tuple2<String,String> p1 = tuple._1();
    Tuple2<String,String> p2 = tuple._2();

    SubstitutionMatrix matrix = SubstitutionMatrixHelper.getBlosum65();
    GapPenalty penalty = new SimpleGapPenalty();
    penalty.setOpenPenalty(8);
    penalty.setExtensionPenalty(1);

    ProteinSequence prot1 = new ProteinSequence(p1._2());
    ProteinSequence prot2 = new ProteinSequence(p2._2());

    try {
        PairwiseSequenceAligner<ProteinSequence, AminoAcidCompound> smithWaterman =
                Alignments.getPairwiseAligner(
                        prot1,
                        prot2,
                        Alignments.PairwiseSequenceAlignerType.LOCAL,
                        penalty,
                        matrix);

        SequencePair<ProteinSequence, AminoAcidCompound> alignment = smithWaterman.getPair();

        if ( debug )
         System.out.println(alignment.toString(60));



        int numIdenticals = alignment.getNumIdenticals();

        int aligLength = alignment.getLength();

        float percentIdenticals = (numIdenticals / (float) aligLength);


        // test overlaps

        int l1 = prot1.getLength();
        int l2 = prot2.getLength();

        int size = alignment.getLength();

        AlignedSequence alignedSequence1 = alignment.getAlignedSequence(1);
        AlignedSequence alignedSequence2 = alignment.getAlignedSequence(2);

        String alignedSeq1 = alignedSequence1.getSequenceAsString().replaceAll("-","");
        String alignedSeq2 = alignedSequence2.getSequenceAsString().replaceAll("-","");

        int size1 = alignedSeq1.length();
        int size2 = alignedSeq2.length();

        float overlap1 = size1 / (float) l1;
        float overlap2 = size2 / (float) l2;

        if ( debug )
            System.out.println(p1._1() + " " + p2._1() + " size:" + size + " l1: " + l1 + " l2: " + l2 + " overlap1 " + overlap1 + " overlap2 " + overlap2 + " %id: " + percentIdenticals);

        return new Tuple5<String, String, Float,Float,Float>(p1._1(),p2._1(),overlap1,overlap2,percentIdenticals);
    } catch (Exception e) {
        System.err.println("Could not align " + p1._1() + " vs." + p2._1());
    }


    return new  Tuple5<String, String, Float,Float,Float>(p1._1(),p2._1(),0f,0f,0f);
}
 
开发者ID:biojava,项目名称:biojava-spark,代码行数:68,代码来源:PairwiseSequenceComparison.java

示例9: call

import org.biojava.nbio.alignment.template.PairwiseSequenceAligner; //导入方法依赖的package包/类
@Override
public Tuple5<String,String,Float,Float,Float> call(Tuple2<Tuple2<String,String>,Tuple2<String,String>> tuple) throws Exception {

	Tuple2<String,String> p1 = tuple._1();
	Tuple2<String,String> p2 = tuple._2();

	SubstitutionMatrix<AminoAcidCompound> matrix = SubstitutionMatrixHelper.getBlosum65();
	GapPenalty penalty = new SimpleGapPenalty();
	penalty.setOpenPenalty(8);
	penalty.setExtensionPenalty(1);

	ProteinSequence prot1 = new ProteinSequence(p1._2());
	ProteinSequence prot2 = new ProteinSequence(p2._2());

	try {
		PairwiseSequenceAligner<ProteinSequence, AminoAcidCompound> smithWaterman = Alignments.getPairwiseAligner(prot1,
				prot2,
				Alignments.PairwiseSequenceAlignerType.LOCAL, penalty, matrix);

		SequencePair<ProteinSequence, AminoAcidCompound> alignment = smithWaterman.getPair();

		if ( debug )
			System.out.println(alignment.toString(60));



		int numIdenticals = alignment.getNumIdenticals();

		int aligLength = alignment.getLength();

		float percentIdenticals = (numIdenticals / (float) aligLength);


		// test overlaps

		int l1 = prot1.getLength();
		int l2 = prot2.getLength();

		int size = alignment.getLength();

		float overlap1 = l1 / (float) size;
		float overlap2 = l2 / (float) size;

		if ( debug )
			System.out.println(p1._1() + " " + p2._1() + " size:" + size + " l1: " + l1 + " l2: " + l2 + " overlap1 " + overlap1 + " overlap2 " + overlap2 + " %id: " + percentIdenticals);


		return new Tuple5<String, String, Float,Float,Float>(p1._1(),p2._1(),overlap1,overlap2,percentIdenticals);
	} catch (Exception e) {
		e.printStackTrace();
	}


	return new  Tuple5<String, String, Float,Float,Float>(p1._1(),p2._1(),0f,0f,0f);
}
 
开发者ID:biojava,项目名称:biojava-spark,代码行数:56,代码来源:PairwiseSequenceComparison.java


注:本文中的org.biojava.nbio.alignment.template.PairwiseSequenceAligner.getPair方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。