use of com.github.lindenb.jvarkit.util.bio.fasta.FastaSequenceReader in project jvarkit by lindenb.
the class TestNg01 method testRefGenomeFactoryForFile.
@Test
public void testRefGenomeFactoryForFile() throws IOException {
final ReferenceGenomeFactory rgf = new ReferenceGenomeFactory();
rgf.setBufferSize(2);
final ReferenceGenome ref = rgf.open(TOY_FA);
final FastaSequenceReader fsr = new FastaSequenceReader();
final List<FastaSequence> seqs = fsr.readAll(new File(TOY_FA));
Assert.assertEquals(seqs.size(), ref.size());
for (int i = 0; i < seqs.size(); i++) {
Assert.assertEquals(ref.getContig(i).length(), seqs.get(i).length());
Assert.assertEquals(ref.getContig(i).getContig(), seqs.get(i).getName());
for (int x = 0; x < ref.getContig(i).length(); ++x) {
Assert.assertEquals(ref.getContig(i).charAt(x), seqs.get(i).charAt(x));
}
}
ref.close();
}
use of com.github.lindenb.jvarkit.util.bio.fasta.FastaSequenceReader in project jvarkit by lindenb.
the class FastaBatchReader method doOpen.
@Override
protected void doOpen() throws Exception {
Objects.requireNonNull(getResource(), "Input resource must be set");
if (LOG.isInfoEnabled())
LOG.info("opening " + getResource());
if (!this.getResource().isReadable())
throw new IllegalStateException("Resource is not readable.");
final FastaSequenceReader fastaReader = new FastaSequenceReader();
fastaReader.setSequenceCapacity(getSequenceCapacity());
this.fastaIterator = fastaReader.iterator(new InputStreamReader(this.getResource().getInputStream()));
}
Aggregations