本文整理汇总了Java中org.biojava.bio.seq.io.SeqIOTools类的典型用法代码示例。如果您正苦于以下问题:Java SeqIOTools类的具体用法?Java SeqIOTools怎么用?Java SeqIOTools使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SeqIOTools类属于org.biojava.bio.seq.io包,在下文中一共展示了SeqIOTools类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readReference
import org.biojava.bio.seq.io.SeqIOTools; //导入依赖的package包/类
private Sequence readReference() throws IOException, BioException {
Sequence sequence = null;
BufferedReader reader = null;
try {
reader = reader(referenceFastaFile);
SequenceIterator sequences = SeqIOTools.readFastaDNA(reader);
if (!sequences.hasNext()) {
throw new IOException("reference FASTA file was empty");
}
sequence = sequences.nextSequence();
if (sequences.hasNext()) {
throw new IOException("reference FASTA file contains more than one sequence");
}
}
finally {
try {
reader.close();
}
catch (Exception e) {
// ignore
}
}
return sequence;
}
示例2: readScaffolds
import org.biojava.bio.seq.io.SeqIOTools; //导入依赖的package包/类
private List<Sequence> readScaffolds() throws IOException, BioException {
BufferedReader reader = null;
List<Sequence> scaffolds = Lists.newLinkedList();
try {
reader = reader(scaffoldsFastaFile);
for (SequenceIterator sequences = SeqIOTools.readFastaDNA(reader); sequences.hasNext(); ) {
Sequence sequence = sequences.nextSequence();
scaffolds.add(sequence);
}
}
finally {
try {
reader.close();
}
catch (Exception e) {
// ignore
}
}
return scaffolds;
}
示例3: createSequences
import org.biojava.bio.seq.io.SeqIOTools; //导入依赖的package包/类
/**
* Create and return zero or more DNA HML Sequences read from the specified reader in FASTA format.
*
* @param reader reader to read from, must not be null
* @return zero or more DNA HML Sequences read from the specified reader in FASTA format
* @throws IOException if an I/O error occurs
*/
public static Iterable<Sequence> createSequences(final BufferedReader reader) throws IOException {
checkNotNull(reader);
List<Sequence> sequences = new ArrayList<Sequence>();
for (SequenceIterator it = SeqIOTools.readFastaDNA(reader); it.hasNext(); ) {
try {
sequences.add(createSequence(it.nextSequence()));
}
catch (BioException e) {
throw new IOException("could not read DNA sequences", e);
}
}
return sequences;
}
示例4: readFasta
import org.biojava.bio.seq.io.SeqIOTools; //导入依赖的package包/类
/**
* Extract consensus sequences from a file in HML format.
*
* @param inputHmlFile input HML file, if any
*/
static Map<String, String> readFasta(final File inputFastqFile) throws IOException, NoSuchElementException, BioException{
BufferedReader reader = null;
HashMap<String, String> fasta = new HashMap<String, String>();
try{
reader = reader(inputFastqFile);
for (SequenceIterator sequences = SeqIOTools.readFastaDNA(reader); sequences.hasNext(); )
{
Sequence sequence = sequences.nextSequence();
String sequenceId = sequence.getName();
String fastaSeq = sequence.seqString();
fasta.put(sequenceId, fastaSeq);
}
}finally {
try {
reader.close();
}
catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
return fasta;
}
示例5: writeSequenceToTempFile
import org.biojava.bio.seq.io.SeqIOTools; //导入依赖的package包/类
/**
* Write the specified sequence to a temporary file in FASTA format.
*
* @param sequence sequence to write
* @return temporary file in FASTA format
* @throws IOException if an I/O error occurs
*/
static File writeSequenceToTempFile(final Sequence sequence) throws IOException {
File tmp = File.createTempFile(sequence.getName() + "-", ".fa");
try (FileOutputStream outputStream = new FileOutputStream(tmp)) {
SeqIOTools.writeFasta(outputStream, sequence);
}
return tmp;
}
示例6: read
import org.biojava.bio.seq.io.SeqIOTools; //导入依赖的package包/类
private static Sequence read(final String name) throws Exception {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(AbstractPairwiseAlignmentTest.class.getResourceAsStream(name)))) {
SequenceIterator sequences = SeqIOTools.readFastaDNA(reader);
return sequences.hasNext() ? sequences.nextSequence() : null;
}
}