本文整理汇总了Java中org.biojava3.core.sequence.ProteinSequence类的典型用法代码示例。如果您正苦于以下问题:Java ProteinSequence类的具体用法?Java ProteinSequence怎么用?Java ProteinSequence使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProteinSequence类属于org.biojava3.core.sequence包,在下文中一共展示了ProteinSequence类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: translateMultiFasta
import org.biojava3.core.sequence.ProteinSequence; //导入依赖的package包/类
/**
* Translates a DNA multi-fasta file into ammino acids
* @param fastaDnaFile the input DNA multi-fasta file
* @param fastaProteinFile the output protein multi-fasta file
* @throws Exception
*/
public void translateMultiFasta(File fastaDnaFile, File fastaProteinFile) throws Exception
{
LinkedHashMap<String, DNASequence> dnaSeqs = FastaReaderHelper.readFastaDNASequence(fastaDnaFile);
//FastaReaderHelper.readFastaDNASequence for DNA sequences
Writer out = new BufferedWriter(new FileWriter(fastaProteinFile));
for (Entry<String, DNASequence> entry : dnaSeqs.entrySet())
{
//System.out.println(entry.getValue().getOriginalHeader() + "=" + entry.getValue().getSequenceAsString());
RNASequence rna = entry.getValue().getRNASequence();
ProteinSequence aa = rna.getProteinSequence();
out.write(">" + entry.getKey() + "\n");
out.write(aa + "\n");
}
out.close();
}
示例2: testFastqToFastaSixFrameTranslation
import org.biojava3.core.sequence.ProteinSequence; //导入依赖的package包/类
/**
* Test of fastqToFastaSixFrameTranslation method, of class FastqParser.
*/
@Test
public void testFastqToFastaSixFrameTranslation() throws Exception
{
System.out.println("fastqToFastaSixFrameTranslation");
File fastqIn = new File("test/test_data_in/piculus_test_left.fastq");
File fastaOut = new File("test/test_data_out/piculus_test_left_translated.fasta");
boolean includeDNASeq = false;
FastqParser instance = new FastqParser();
instance.fastqToFastaSixFrameTranslation(fastqIn, fastaOut, includeDNASeq);
long fastqCount = FastqQCTest.countLines(fastqIn);
long fastaCount = FastqQCTest.countLines(fastaOut);
//for every fastq seq (4 lines) there should be 6 fasta seqs (12 lines)
assertEquals(fastqCount, fastaCount / 3);
LinkedHashMap<String, ProteinSequence> seqs = FastaReaderHelper.readFastaProteinSequence(fastaOut);
//there should be 6 protein sequences for every fastq
assertEquals((fastqCount / 4) * 6, seqs.values().size());
//include the DNA sequence so there should be 7 protein sequences for every fastq
includeDNASeq = true;
instance.fastqToFastaSixFrameTranslation(fastqIn, fastaOut, includeDNASeq);
fastqCount = FastqQCTest.countLines(fastqIn);
seqs = FastaReaderHelper.readFastaProteinSequence(fastaOut);
assertEquals((fastqCount / 4) * 7, seqs.values().size());
}
示例3: n50avaluation
import org.biojava3.core.sequence.ProteinSequence; //导入依赖的package包/类
private void n50avaluation(CommandLine cl) throws Exception {
ArrayList<Integer> lenghts = new ArrayList<Integer>();
LinkedHashMap<String, ProteinSequence> a = FastaReaderHelper
.readFastaProteinSequence(new File(cl.getOptionValue("n50")));
for (Entry<String, ProteinSequence> entry : a.entrySet()) {
int l = entry.getValue().getLength();
lenghts.add(l);
}
System.out.println("Number of sequences in the file: " + lenghts.size());
System.out.println("N50: " + N50.n50(lenghts));
System.out.println("----------------------");
}
示例4: translateFasta
import org.biojava3.core.sequence.ProteinSequence; //导入依赖的package包/类
/**
* Translate a DNASequence into a ProteinSequence
* @param dna the DNASequence to be translated
* @return the translated ProteinSequence
* @throws Exception
*/
public ProteinSequence translateFasta(DNASequence dna) throws Exception
{
RNASequence rna = dna.getRNASequence();
ProteinSequence aa = rna.getProteinSequence();
System.out.println(dna.getAccession());
System.out.println(aa);
aa.setAccession(dna.getAccession());
return aa;
}
示例5: testTranslateFasta
import org.biojava3.core.sequence.ProteinSequence; //导入依赖的package包/类
/**
* Test of translateFasta method, of class FastaTranslator.
*/
@Test
public void testTranslateFasta() throws Exception
{
System.out.println("translateFasta");
AccessionID id = new AccessionID("seq1");
DNASequence dna = new DNASequence("atg");
dna.setAccession(id);
FastaTranslator instance = new FastaTranslator();
ProteinSequence result = instance.translateFasta(dna);
assertEquals(result.toString(), "M");
}
示例6: getSequenceForId
import org.biojava3.core.sequence.ProteinSequence; //导入依赖的package包/类
private static ProteinSequence getSequenceForId(String uniProtId) throws Exception {
try (InputStream stream = new URL(String.format(URL, uniProtId)).openStream()) {
return FastaReaderHelper.readFastaProteinSequence(stream).get(uniProtId); // why does this throw Exception?
}
}