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


Java NucleotideCompound类代码示例

本文整理汇总了Java中org.biojava.nbio.core.sequence.compound.NucleotideCompound的典型用法代码示例。如果您正苦于以下问题:Java NucleotideCompound类的具体用法?Java NucleotideCompound怎么用?Java NucleotideCompound使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NucleotideCompound类属于org.biojava.nbio.core.sequence.compound包,在下文中一共展示了NucleotideCompound类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAlign

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
@Test
	public void testAlign() throws Exception {
		DNASequence a = new DNASequence("C GTAT  ATATCGCGCGC G CGATATATATATCT TCTCTAAAAAAA".replaceAll(" ", ""));
		DNASequence b = new DNASequence("G GTATATATATCGCGCGC A CGAT TATATATCTCTCTCTAAAAAAA".replaceAll(" ", ""));
//                                       --CGTATATATCGCGCGCGCGATATATATATCT-TCTCTAAAAAAA
//                                       GGTATATATATCGCGCGCACGAT-TATATATCTCTCTCTAAAAAAA
//  mismatches:                             ^              ^
// OR:
//		                                 CG--TATATATCGCGCGCGCGATATATATATCT-TCTCTAAAAAAA
//		                                 GGTATATATATCGCGCGCACGAT-TATATATCTCTCTCTAAAAAAA
		SequenceAligner<DNASequence, NucleotideCompound> aligner = getGlobalAligner();
		SequenceAlignment<DNASequence, NucleotideCompound> alignment = aligner.align(a, b);
		int nMatches = "--CGTATATATCGCGCGCGCGATATATATATCT-TCTCTAAAAAAA".length() - 2 - 4;
		double expectedScore = nMatches * sf_m
				+				                       - 2 * sf_m // there are two mismatches
				+ + 3 * sf_gop + 4 * sf_gep; // there are 3 gap opens and either 1 or 4 extensions, depending on the def
		assertEquals(expectedScore, alignment.getScore(), 0.00000001);
		assertEquals(3, alignment.getNInsertionsInA());
		assertEquals(1, alignment.getNInsertionsInB());
		assertEquals(2, alignment.getNInsertionOpensInA());
		assertEquals(1, alignment.getNInsertionOpensInB());
	}
 
开发者ID:dmyersturnbull,项目名称:sequence-alignment,代码行数:23,代码来源:SequenceAlignerTest.java

示例2: getCodonCompoundSet

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/**
	 * Returns the compound set of codons
	 */
	@Override
public CompoundSet<Codon> getCodonCompoundSet(
			final CompoundSet<NucleotideCompound> rnaCompounds,
			final CompoundSet<AminoAcidCompound> aminoAcidCompounds) {
		if (compounds == null) {
			compounds = new AbstractCompoundSet<Codon>() {
				{
					for (Codon c : getCodons(rnaCompounds, aminoAcidCompounds)) {
						addCompound(c);
					}
				}
			};
		}
		return compounds;
	}
 
开发者ID:biojava,项目名称:biojava,代码行数:19,代码来源:IUPACParser.java

示例3: testDNAMultipleAlignmentWithMixedCompoundSets

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/**
 * @author brandstaetter
 */
public void testDNAMultipleAlignmentWithMixedCompoundSets() throws CompoundNotFoundException {

	DNASequence target = new DNASequence("ACTGACGTGTAGCTGACTGA", DNACompoundSet.getDNACompoundSet());
	DNASequence query = new DNASequence("ACTGACGTGTAGCTGACTGTA", AmbiguityDNACompoundSet.getDNACompoundSet());

	List<DNASequence> lst = new ArrayList<DNASequence>();
	lst.add(target);
	lst.add(query);

	try {
		@SuppressWarnings("unused")
		Profile<DNASequence, NucleotideCompound> profile = Alignments.getMultipleSequenceAlignment(lst);
		fail("Alignments.getMultipleSequenceAlignment(lst) expected exception with differing compound sets");
	} catch (IllegalArgumentException ex) {
		// expected exception
	}
}
 
开发者ID:biojava,项目名称:biojava,代码行数:21,代码来源:TestDNAAlignment.java

示例4: readFastaRNASequence

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/**
 * Selecting lazySequenceLoad=true will parse the FASTA file and figure out the accessionid and offsets and return sequence objects
 * that can in the future read the sequence from the disk. This allows the loading of large fasta files where you are only interested
 * in one sequence based on accession id.
 * @param file
 * @param lazySequenceLoad
 * @return
 * @throws IOException
 */
public static LinkedHashMap<String, RNASequence> readFastaRNASequence(File file, boolean lazySequenceLoad) throws IOException {
	if (!lazySequenceLoad) {
		return readFastaRNASequence(file);
	}

	FastaReader<RNASequence, NucleotideCompound> fastaProxyReader =
			new FastaReader<RNASequence, NucleotideCompound>(
					file,
					new GenericFastaHeaderParser<RNASequence, NucleotideCompound>(),
					new FileProxyRNASequenceCreator(
							file,
							RNACompoundSet.getRNACompoundSet(),
							new FastaSequenceParser()
						)
				);
	return fastaProxyReader.process();

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

示例5: getTranscriptDNASequence

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/** Extracts the DNA sequence transcribed from the input genetic coordinates.
   *
   * @param chromosome the name of the chromosome
   * @param exonStarts The list holding the genetic coordinates pointing to the start positions of the exons (including UTR regions)  
   * @param exonEnds The list holding the genetic coordinates pointing to the end positions of the exons (including UTR regions)
   * @param cdsStart The start position of a coding region
   * @param cdsEnd The end position of a coding region
   * @param orientation The orientation of the strand where the gene is living
   * 
   * @return the DNA sequence transcribed from the input genetic coordinates
   */
public static DNASequence getTranscriptDNASequence(TwoBitFacade twoBitFacade, String chromosome, List<Integer> exonStarts, List<Integer> exonEnds, int cdsStart, int cdsEnd, Character orientation) throws Exception {

	List<Range<Integer>> cdsRegion = getCDSRegions(exonStarts, exonEnds, cdsStart, cdsEnd);

	String dnaSequence = "";
	for (Range<Integer> range : cdsRegion) {
		String exonSequence = twoBitFacade.getSequence(chromosome,range.lowerEndpoint(), range.upperEndpoint());
           dnaSequence += exonSequence;
	}
	if (orientation.equals('-')) {
           dnaSequence = new StringBuilder(dnaSequence).reverse().toString();
		DNASequence dna = new DNASequence(dnaSequence);
		SequenceView<NucleotideCompound> compliment = dna.getComplement();
           dnaSequence = compliment.getSequenceAsString();
	}
	return new DNASequence(dnaSequence.toUpperCase());
}
 
开发者ID:biojava,项目名称:biojava,代码行数:29,代码来源:ChromosomeMappingTools.java

示例6: testCreateDNASequenceWithQualityScoresAndErrorProbabilities

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
public void testCreateDNASequenceWithQualityScoresAndErrorProbabilities() throws CompoundNotFoundException
{
	DNASequence sequence = FastqTools.createDNASequenceWithQualityScoresAndErrorProbabilities(builder.build());
	assertNotNull(sequence);

	List<FeatureInterface<AbstractSequence<NucleotideCompound>, NucleotideCompound>> qualityScoresFeatures = sequence.getFeaturesByType("qualityScores");
	assertNotNull(qualityScoresFeatures);
	assertEquals(1, qualityScoresFeatures.size());
	QualityFeature<AbstractSequence<NucleotideCompound>, NucleotideCompound> qualityScores = (QualityFeature<AbstractSequence<NucleotideCompound>, NucleotideCompound>) qualityScoresFeatures.get(0);
	assertEquals(sequence.getLength(), qualityScores.getQualities().size());
	assertEquals(sequence.getLength(), qualityScores.getLocations().getLength());

	List<FeatureInterface<AbstractSequence<NucleotideCompound>, NucleotideCompound>> errorProbabilitiesFeatures = sequence.getFeaturesByType("errorProbabilities");
	assertNotNull(errorProbabilitiesFeatures);
	assertEquals(1, errorProbabilitiesFeatures.size());
	QuantityFeature<AbstractSequence<NucleotideCompound>, NucleotideCompound> errorProbabilities = (QuantityFeature<AbstractSequence<NucleotideCompound>, NucleotideCompound>) errorProbabilitiesFeatures.get(0);
	assertEquals(sequence.getLength(), errorProbabilities.getQuantities().size());
	assertEquals(sequence.getLength(), errorProbabilities.getLocations().getLength());
}
 
开发者ID:biojava,项目名称:biojava,代码行数:20,代码来源:FastqToolsTest.java

示例7: testBasicCircularLocation

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
@Test
public void testBasicCircularLocation() throws CompoundNotFoundException {
	Location circularLocation = new SimpleLocation(
			new SimplePoint(3), new SimplePoint(52), Strand.POSITIVE, true,
			new SimpleLocation(3, 20, Strand.POSITIVE),
			new SimpleLocation(1, 20, Strand.POSITIVE),
			new SimpleLocation(1, 12, Strand.POSITIVE));
	assertEquals("Checking length as expected", circularLocation.getLength(), 50);

	String expectedDna = "CCCCTTTTGGGGGGGGGGAACCCCTTTTGGGGGGGGGGAACCCCTTTTGG";
	DNASequence s = new DNASequence("AACCCCTTTTGGGGGGGGGG");
	Sequence<NucleotideCompound> subSeq = circularLocation.getSubSequence(s);
	assertEquals("Checking subseq as expected", expectedDna, subSeq.getSequenceAsString());


	Location newCircularLocation = Location.Tools.circularLocation(
			3, 52, Strand.POSITIVE, 20);
	//Check this is the right set of coords even to use!
	Location negativeCoordsCircularLocation = Location.Tools.circularLocation(
			58,9, Strand.POSITIVE, 20);

	assertEquals("location objects should be equivalent", circularLocation, newCircularLocation);
	assertEquals("location objects should be equivalent even if they are on the wrong coord system", circularLocation.getSubLocations(), negativeCoordsCircularLocation.getSubLocations());
	assertEquals("Checking subseq as expected", expectedDna,
			newCircularLocation.getSubSequence(s).getSequenceAsString());
}
 
开发者ID:biojava,项目名称:biojava,代码行数:27,代码来源:LocationTest.java

示例8: getSequence5PrimeTo3Prime

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/**
 * Try to give method clarity where you want a DNASequence coding in the 5' to 3' direction
 * Returns the DNASequence representative of the 5' and 3' reading based on strand
 * @return dna sequence
 */
public DNASequence getSequence5PrimeTo3Prime() {
	String sequence = getSequenceAsString(this.getBioBegin(), this.getBioEnd(), this.getStrand());
	if (getStrand() == Strand.NEGATIVE) {
		//need to take complement of sequence because it is negative and we are returning the gene sequence from the opposite strand
		StringBuilder b = new StringBuilder(getLength());
		CompoundSet<NucleotideCompound> compoundSet = this.getCompoundSet();
		for (int i = 0; i < sequence.length(); i++) {
			String nucleotide = String.valueOf(sequence.charAt(i));
			NucleotideCompound nucleotideCompound = compoundSet.getCompoundForString(nucleotide);
			b.append(nucleotideCompound.getComplement().getShortName());
		}
		sequence = b.toString();
	}
	DNASequence dnaSequence = null;
	try {
		dnaSequence = new DNASequence(sequence.toUpperCase());
	} catch (CompoundNotFoundException e) {
		// this should not happen, the sequence is DNA originally, if it does, there's a bug somewhere
		logger.error("Could not create new DNA sequence in getSequence5PrimeTo3Prime(). Error: {}",e.getMessage());
	}
	dnaSequence.setAccession(new AccessionID(this.getAccession().getID()));
	return dnaSequence;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:29,代码来源:GeneSequence.java

示例9: getCodingSequence

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/**
 * A CDS sequence if negative stranded needs to be reverse complement
 * to represent the actual coding sequence. When getting a ProteinSequence
 * from a TranscriptSequence this method is callled for each CDSSequence
 * {@link http://www.sequenceontology.org/gff3.shtml}
 * {@link http://biowiki.org/~yam/bioe131/GFF.ppt}
 * @return coding sequence
 */
public String getCodingSequence() {
	String sequence = this.getSequenceAsString(getBioBegin(), getBioEnd(), getStrand());

	if (getStrand() == Strand.NEGATIVE) {
		//need to take complement of sequence because it is negative and we are returning a coding sequence
		StringBuilder b = new StringBuilder(getLength());
		CompoundSet<NucleotideCompound> compoundSet = this.getCompoundSet();
		for (int i = 0; i < sequence.length(); i++) {
			String nucleotide = String.valueOf(sequence.charAt(i));
			NucleotideCompound nucleotideCompound = compoundSet.getCompoundForString(nucleotide);
			b.append(nucleotideCompound.getComplement().getShortName());
		}
		sequence = b.toString();
	}
	//  sequence = sequence.substring(phase);
	return sequence;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:26,代码来源:CDSSequence.java

示例10: compoundToInt

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
public int compoundToInt(NucleotideCompound c) {
			char b = c.getUpperedBase().charAt(0);
			return b;
//            int v = -1;
//            if('A' == b) {
//                v = 1;
//            }
//            else if('C' == b) {
//                v = 2;
//            }
//            else if('G' == b) {
//                v = 3;
//            }
//            else if('T' == b || 'U' == b) {
//                v = 4;
//            }
//            return v;
		}
 
开发者ID:biojava,项目名称:biojava,代码行数:19,代码来源:Table.java

示例11: main

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
public static void main(String[] args) {

		try {
			ArrayList<GeneSequence> sequences = new ArrayList<GeneSequence>();
			ChromosomeSequence seq1 = new ChromosomeSequence("ATATATATATATATATATATATATATATATATACGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCATATATATATATATATATATATACGCGCGCGCGCGCGCGCATATATATATATATATATATATATATATATATACGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCATATATATATATATATATATATACGCGCGCGCGCGCGCGC");
			GeneSequence gene1 = seq1.addGene(new AccessionID("gene1"), 1, 20, Strand.POSITIVE);

			gene1.addExon(new AccessionID("t1_1_10"), 1, 10);
			gene1.addExon(new AccessionID("t1_12_15"), 12, 15);
			GeneSequence gene2 = seq1.addGene(new AccessionID("gene2"), 1, 20, Strand.NEGATIVE);

			gene2.addExon(new AccessionID("t2_1_10"), 1, 10);
			gene2.addExon(new AccessionID("t2_12_15"), 12, 15);
			sequences.add(gene1);
			sequences.add(gene2);


			FastaGeneWriter fastaWriter = new FastaGeneWriter(System.out, sequences, new GenericFastaHeaderFormat<GeneSequence, NucleotideCompound>(), true);
			fastaWriter.process();


		} catch (Exception e) {
			logger.warn("Exception: ", e);
		}
	}
 
开发者ID:biojava,项目名称:biojava,代码行数:26,代码来源:FastaGeneWriter.java

示例12: getCompound

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
private NucleotideCompound getCompound(List<String> compounds,
		int position, CompoundSet<NucleotideCompound> nucelotides) {
	String compound = compounds.get(position);
	NucleotideCompound returnCompound = nucelotides
			.getCompoundForString(compound);
	if (returnCompound == null) {
		if ("T".equalsIgnoreCase(compound)) {
				returnCompound = nucelotides.getCompoundForString("U");
		}
		else {
			throw new ParserException("Cannot find a compound for string "
					+ compound);
		}
	}
	return returnCompound;
}
 
开发者ID:biojava,项目名称:biojava,代码行数:17,代码来源:IUPACParser.java

示例13: readGenbankDNASequence

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/**
 * Selecting lazySequenceLoad=true will parse the Genbank file and figure out the accessionid and offsets and return sequence objects
 * that can in the future read the sequence from the disk. This allows the loading of large Genbank files where you are only interested
 * in one sequence based on accession id.
 * @param file
 * @param lazySequenceLoad
 * @return
 * @throws Exception
 */
public static LinkedHashMap<String, DNASequence> readGenbankDNASequence(File file, boolean lazySequenceLoad) throws Exception {
	if (!lazySequenceLoad) {
		return readGenbankDNASequence(file);
	}

	GenbankReader<DNASequence, NucleotideCompound> GenbankProxyReader =
			new GenbankReader<DNASequence, NucleotideCompound>(
					file,
					new GenericGenbankHeaderParser<DNASequence, NucleotideCompound>(),
					new FileProxyDNASequenceCreator(
							file,
							DNACompoundSet.getDNACompoundSet(),
							new GenbankSequenceParser<AbstractSequence<NucleotideCompound>, NucleotideCompound>()
						)
				);
	return GenbankProxyReader.process();

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

示例14: readGenbankRNASequence

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
/**
 * Selecting lazySequenceLoad=true will parse the Genbank file and figure out the accessionid and offsets and return sequence objects
 * that can in the future read the sequence from the disk. This allows the loading of large Genbank files where you are only interested
 * in one sequence based on accession id.
 * @param file
 * @param lazySequenceLoad
 * @return
 * @throws Exception
 */
public static LinkedHashMap<String, RNASequence> readGenbankRNASequence(File file, boolean lazySequenceLoad) throws Exception {
	if (!lazySequenceLoad) {
		return readGenbankRNASequence(file);
	}

	GenbankReader<RNASequence, NucleotideCompound> GenbankProxyReader =
			new GenbankReader<RNASequence, NucleotideCompound>(
					file,
					new GenericGenbankHeaderParser<RNASequence, NucleotideCompound>(),
					new FileProxyRNASequenceCreator(
							file,
							RNACompoundSet.getRNACompoundSet(),
							new GenbankSequenceParser<AbstractSequence<NucleotideCompound>, NucleotideCompound>()
						)
				);
	return GenbankProxyReader.process();

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

示例15: testPerfect

import org.biojava.nbio.core.sequence.compound.NucleotideCompound; //导入依赖的package包/类
@Test
public void testPerfect() throws Exception {
	DNASequence a = new DNASequence("ACTAACCGAGATTTTACCCCACGGTATTTTTT");
	DNASequence b = new DNASequence("ACTAACCGAGATTTTACCCCACGGTATTTTTT");
	SequenceAligner<DNASequence, NucleotideCompound> aligner = getGlobalAligner();
	SequenceAlignment<DNASequence, NucleotideCompound> alignment = aligner.align(a, b);
	assertEquals(sf_m * "ACTAACCGAGATTTTACCCCACGGTATTTTTT".length(), alignment.getScore(), 0.00000001);
}
 
开发者ID:dmyersturnbull,项目名称:sequence-alignment,代码行数:9,代码来源:SequenceAlignerTest.java


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