本文整理汇总了Java中org.biojava.nbio.core.sequence.compound.AminoAcidCompound类的典型用法代码示例。如果您正苦于以下问题:Java AminoAcidCompound类的具体用法?Java AminoAcidCompound怎么用?Java AminoAcidCompound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AminoAcidCompound类属于org.biojava.nbio.core.sequence.compound包,在下文中一共展示了AminoAcidCompound类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterSequenceSimilar
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
/**
* Filter the {@link SegmentDataRDD} based on minimum sequence similarity to a reference sequence.
* @param inputSequence the reference sequence to compare
* @param minSimilarity the minimum similarity (as a double between 0.00 and 1.00)
* @return the {@link SegmentDataRDD} after being filtered
* @throws CompoundNotFoundException if Biojava cannot accurately convert the String sequence to a {@link ProteinSequence}
*/
public static SegmentDataRDD filterSequenceSimilar(SegmentDataRDD segmentDataRDD, String inputSequence, double minSimilarity) throws CompoundNotFoundException {
ProteinSequence proteinSequence = new ProteinSequence(inputSequence);
// First set up the environment
int gop = 8;
int extend = 1;
GapPenalty penalty = new SimpleGapPenalty();
penalty.setOpenPenalty(gop);
penalty.setExtensionPenalty(extend);
SubstitutionMatrix<AminoAcidCompound> matrix = SubstitutionMatrixHelper.getBlosum65();
return new SegmentDataRDD(segmentDataRDD.getSegmentRDD().filter(t -> {
ProteinSequence otherSequence = new ProteinSequence(t._2.getSequence());
PairwiseSequenceAligner<ProteinSequence, AminoAcidCompound> smithWaterman =
Alignments.getPairwiseAligner(proteinSequence, otherSequence, PairwiseSequenceAlignerType.LOCAL, penalty, matrix);
if(smithWaterman.getSimilarity()<minSimilarity){
return false;
}
return true;
}));
}
示例2: swAlignment
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
private void swAlignment() throws CompoundNotFoundException {
ProteinSequence s1 = new ProteinSequence(query);
s1.setAccession(new AccessionID("Query"));
ProteinSequence s2 = new ProteinSequence(subject);
s2.setAccession(new AccessionID("Subject"));
SubstitutionMatrix<AminoAcidCompound> matrix
= SimpleSubstitutionMatrix.getBlosum62();
alignment = Alignments.getPairwiseAlignment(s1, s2,
Alignments.PairwiseSequenceAlignerType.LOCAL,
new SimpleGapPenalty(), matrix);
FractionalSimilarityScorer<ProteinSequence, AminoAcidCompound> scorer =
new FractionalSimilarityScorer<>(alignment);
score = scorer.getScore();
}
示例3: testProcessAll
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
private void testProcessAll(String path) throws Exception {
ClasspathResource r = new ClasspathResource(path);
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = null ;
try( InputStream inStream = r.getInputStream() ) {
fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
inStream,
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
LinkedHashMap<String, ProteinSequence> sequences = fastaReader.process();
assertThat(sequences,is(notNullValue()));
assertThat(sequences.size(),is(1));
assertThat(sequences.containsKey("P02768"),is(true));
assertThat(sequences.get("P02768").getLength(),is(609));
} finally {
if(fastaReader != null) fastaReader.close();
}
}
示例4: readGenbankProteinSequence
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的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, ProteinSequence> readGenbankProteinSequence(File file, boolean lazySequenceLoad) throws Exception {
if (!lazySequenceLoad) {
return readGenbankProteinSequence(file);
}
GenbankReader<ProteinSequence, AminoAcidCompound> GenbankProxyReader =
new GenbankReader<ProteinSequence, AminoAcidCompound>(
file,
new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(),
new FileProxyProteinSequenceCreator(
file,
AminoAcidCompoundSet.getAminoAcidCompoundSet(),
new GenbankSequenceParser<AbstractSequence<AminoAcidCompound>, AminoAcidCompound>()
)
);
return GenbankProxyReader.process();
}
示例5: testProcess1
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
private void testProcess1(String path) throws Exception {
ClasspathResource r = new ClasspathResource(path);
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = null ;
try( InputStream inStream = r.getInputStream() ) {
fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
inStream,
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
LinkedHashMap<String,ProteinSequence> out1 = fastaReader.process(1);
assertThat(out1,is(notNullValue()));
assertThat(out1.size(),is(1));
assertThat(out1.containsKey("P02768"),is(true));
assertThat(out1.get("P02768").getLength(),is(609));
LinkedHashMap<String,ProteinSequence> out2 = fastaReader.process(1);
assertThat(out2,is(nullValue()));
} finally {
if(fastaReader != null) fastaReader.close();
}
}
示例6: testHashCollision
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
/** test for https://github.com/biojava/biojava/issues/53 */
@Test
public void testHashCollision() throws CompoundNotFoundException{
Builder builder = new TranscriptionEngine.Builder();
builder.initMet(false);
builder.translateNCodons(true);
builder.trimStop(false);
TranscriptionEngine engine = builder.build();
Sequence<AminoAcidCompound> seq=engine.translate(new
DNASequence("GTNTGTTAGTGT"));
assertThat("XC*C", is(seq.toString()));
Sequence<AminoAcidCompound> seq2=engine.translate(new
DNASequence("ANAANG"));
assertEquals("XX",seq2.toString());
assertNotSame("HR",seq2.toString());
}
示例7: getExtinctAACount
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
private Map<AminoAcidCompound, Integer> getExtinctAACount(ProteinSequence sequence){
//Cys => C, Tyr => Y, Trp => W
int numW = 0;
int smallW = 0;
double numC = 0;
double smallC = 0;
int numY = 0;
int smallY = 0;
for(char aa:sequence.getSequenceAsString().toCharArray()){
switch(aa){
case 'W': numW++; break;
case 'w': smallW++; break;
case 'C': numC += 0.5; break;
case 'c': smallC += 0.5; break;
case 'Y': numY++; break;
case 'y': smallY++; break;
}
}
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
Map<AminoAcidCompound, Integer> extinctAA2Count = new HashMap<AminoAcidCompound, Integer>();
//Ignore Case is always true
extinctAA2Count.put(aaSet.getCompoundForString("W"), numW + smallW);
extinctAA2Count.put(aaSet.getCompoundForString("C"), (int) (numC + smallC));
extinctAA2Count.put(aaSet.getCompoundForString("Y"), numY + smallY);
return extinctAA2Count;
}
示例8: getAvgHydropathy
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
@Override
public double getAvgHydropathy(ProteinSequence sequence) {
int validLength = 0;
double total = 0.0;
AminoAcidCompoundSet aaSet = new AminoAcidCompoundSet();
char[] seq = this.getSequence(sequence.toString(), true);
for(char aa:seq){
AminoAcidCompound c = aaSet.getCompoundForString(String.valueOf(aa));
if(Constraints.aa2Hydrophathicity.containsKey(c)){
total += Constraints.aa2Hydrophathicity.get(c);
validLength++;
}
}
if (validLength==0) {
logger.warn("Valid length of sequence is 0, can't divide by 0 to calculate average hydropathy: setting average hydropathy to 0");
return 0.0;
}
return total / validLength;
}
示例9: testProcess2
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
private void testProcess2(String path) throws Exception {
ClasspathResource r = new ClasspathResource(path);
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = null ;
try( InputStream inStream = r.getInputStream() ) {
fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
inStream,
new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
LinkedHashMap<String,ProteinSequence> out1 = fastaReader.process(1);
assertThat(out1,is(notNullValue()));
assertThat(out1.size(),is(1));
assertThat(out1.containsKey("P02768"),is(true));
assertThat(out1.get("P02768").getLength(),is(609));
LinkedHashMap<String,ProteinSequence> out2 = fastaReader.process(1);
assertThat(out2,is(notNullValue()));
assertThat(out2.size(),is(1));
assertThat(out2.containsKey("P00698"),is(true));
assertThat(out2.get("P00698").getLength(),is(147));
LinkedHashMap<String,ProteinSequence> out3 = fastaReader.process(1);
assertThat(out3,is(nullValue()));
} finally {
if(fastaReader != null) fastaReader.close();
}
}
示例10: readInputFile
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
private static LinkedHashMap<String, ProteinSequence> readInputFile(String inputLocation, AminoAcidCompositionTable aaTable) throws Exception{
FileInputStream inStream = new FileInputStream(inputLocation);
CompoundSet<AminoAcidCompound> set;
if(aaTable == null){
set = CaseFreeAminoAcidCompoundSet.getAminoAcidCompoundSet();
}else{
set = aaTable.getAminoAcidCompoundSet();
}
LinkedHashMap<String, ProteinSequence> ret;
if ( inputLocation.toLowerCase().contains(".gb")) {
GenbankReader<ProteinSequence, AminoAcidCompound> genbankReader = new GenbankReader<ProteinSequence, AminoAcidCompound>(
inStream, new GenericGenbankHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(set));
ret = genbankReader.process();
} else {
FastaReader<ProteinSequence, AminoAcidCompound> fastaReader = new FastaReader<ProteinSequence, AminoAcidCompound>(
inStream, new GenericFastaHeaderParser<ProteinSequence, AminoAcidCompound>(),
new ProteinSequenceCreator(set));
ret = fastaReader.process();
}
return ret;
}
示例11: getCodons
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
/**
* Returns a list of codons where the source and target compounds
* are the same as those given by the parameters.
*
* @param nucleotides The nucleotide set to use when building BioJava
* representations of codons
* @param aminoAcids The target amino acid compounds objects
*/
@Override
public List<Codon> getCodons(CompoundSet<NucleotideCompound> nucelotides,
CompoundSet<AminoAcidCompound> aminoAcids) {
if (this.codons.isEmpty()) {
List<String> aminoAcidStrings = aminoAcids();
List<String> startCodonStrings = startCodons();
List<List<String>> codonStrings = codonStrings();
for (int i = 0; i < aminoAcidStrings.size(); i++) {
List<String> codonString = codonStrings.get(i);
NucleotideCompound one = getCompound(codonString, 0, nucelotides);
NucleotideCompound two = getCompound(codonString, 1, nucelotides);
NucleotideCompound three = getCompound(codonString, 2, nucelotides);
boolean start = ("M".equals(startCodonStrings.get(i)));
boolean stop = ("*".equals(aminoAcidStrings.get(i)));
AminoAcidCompound aminoAcid = aminoAcids
.getCompoundForString(aminoAcidStrings.get(i));
codons.add(new Codon(new CaseInsensitiveTriplet(one, two, three), aminoAcid, start, stop));
}
}
return codons;
}
示例12: processing
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
public void processing(Callback callback) throws IOException {
ObjectMapper mapper = new ObjectMapper();
FileInputStream inStream = new FileInputStream( fastaFile );
FastaReader<ProteinSequence,AminoAcidCompound> fastaReader =
new FastaReader<>(
inStream,
new GenericFastaHeaderParser<>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
LinkedHashMap<String, ProteinSequence> b = fastaReader.process();
for ( Map.Entry<String, ProteinSequence> entry : b.entrySet() ) {
String header = entry.getValue().getOriginalHeader();
String sequence = entry.getValue().getSequenceAsString();
String[] parts = header.split("\\|");
ProteinObj obj = new ProteinObj();
if (parts.length < 3)
logger.error("faste parsing error " + header);
else {
obj.setAcxn(parts[1]);
obj.setDefline(parts[2]);
obj.setSequence(sequence);
JsonNode node = mapper.valueToTree(obj);
callback.processSingleJSONRecord(node);
}
}
}
示例13: alignPairLocal
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
private static void alignPairLocal(String id1, String id2) throws Exception {
ProteinSequence s1 = new ProteinSequence("METSSSLPLSPISIEPEQPSHRDYDITTRRGVGTTGNPIELCTNHFNVSVRQPDVVFYQY" +
"TVSITTENGDAVDG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ETIYVGCSFFDVELTEHVCHLTEADFSPQEWKIVSLISRRSGSTFEIRIKTNPPI" +
"YTRGPNALTLENRSELTRIIEAITDQCLHNEKFLLYSSGTFPTKGGDIASPDEVTLIKSG" +
"FVKTTKIVDRDGVPDAIMTVDTTKSPFYKDTSLLKFFTAKMDQLTNSGGGPRGHNGGRER" +
"RDGGGNSRKYDDRRSPRDGEIDYDERTVSHYQRQFQDERISDGMLNTLKQSLKGLDCQPI" +
"HLKDSKANRSIMIDEIHTGTADSVTFEQKLPDGEMKLTSITEYYLQRYNYRLKFPHLPLV" +
"TSKRAKCYDFYPMELMSILPGQRIKQSHMTVDIQSYMTGKMSSLPDQHIKQSKLVLTEYL" +
"KLGDQPANRQMDAFRVSLKSIQPIVTNAHWLSPPDMKFANNQLYSLNPTRGVRFQTNGKF" +
"VMPARVKSVTIINYDKEFNRNVDMFAEGLAKHCSEQGMKFDSRPNSWKKVNLGSSDRRGT" +
"KVEIEEAIRNGVTIVFGIIAEKRPDMHDILKYFEEKLGQQTIQISSETADKFMRDHGGKQ" +
"TIDNVIRKLNPKCGGTNFLIDVPESVGHRVVCNNSAEMRAKLYAKTQFIGFEMSHTGART" +
"RFDIQKVMFDGDPTVVGVAYSLKHSAQLGGFSYFQESRLHKLTNLQEKMQICLNAYEQSS" +
"SYLPETVVVYRVGSGEGDYPQIVNEVNEMKLAARKKKHGYNPKFLVICTQRNSHIRVFPE" +
"HINERGKSMEQNVKSGTCVDVPGASHGYEEFILCCQTPLIGTVKPTKYTIIVNDCRWSKN" +
"EIMNVTYHLAFAHQVSYAPPAIPNVSYAAQNLAKRGHNNYKTHTKLVDMNDYSYRIKEKH" +
"EEIISSEEVDDILMRDFIETVSNDLNAMTINGRNFWA");
SubstitutionMatrix<AminoAcidCompound> matrix = SimpleSubstitutionMatrix.getBlosum62();
SequencePair<ProteinSequence, AminoAcidCompound> pair = Alignments.getPairwiseAlignment(s1, s2,
Alignments.PairwiseSequenceAlignerType.LOCAL, new SimpleGapPenalty(), matrix);
System.out.printf("%n%s vs %s%n%s", pair.getQuery().getAccession(), pair.getTarget().getAccession(), pair);
}
示例14: main
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
//Try reading with the FastaReader
FileInputStream inStream = new FileInputStream(BASE_PATH);
FastaReader<ProteinSequence,AminoAcidCompound> fastaReader =
new FastaReader<>(inStream,
new GenericFastaHeaderParser<ProteinSequence,AminoAcidCompound>(),
new ProteinSequenceCreator(AminoAcidCompoundSet.getAminoAcidCompoundSet()));
LinkedHashMap<String, ProteinSequence> b = fastaReader.process();
for ( Map.Entry<String, ProteinSequence> entry : b.entrySet() ) {
System.out.println(entry.getValue().getOriginalHeader());
}
}
示例15: getKimuraTree
import org.biojava.nbio.core.sequence.compound.AminoAcidCompound; //导入依赖的package包/类
/**
* Calculate a phylogenetic tree of the MultipleAlignment using Kimura
* distances and the Neighbor Joining algorithm from forester.
*
* @param msta
* MultipleAlignment of protein structures
* @return Phylogeny phylogenetic tree
* @throws CompoundNotFoundException
* @throws IOException
*/
public static Phylogeny getKimuraTree(MultipleAlignment msta)
throws CompoundNotFoundException, IOException {
MultipleSequenceAlignment<ProteinSequence, AminoAcidCompound> msa = MultipleAlignmentTools
.toProteinMSA(msta);
BasicSymmetricalDistanceMatrix distmat = (BasicSymmetricalDistanceMatrix) DistanceMatrixCalculator
.kimuraDistance(msa);
Phylogeny tree = TreeConstructor.distanceTree(distmat,
TreeConstructorType.NJ);
tree.setName("Kimura Tree");
return tree;
}