public void testWorks() throws Exception {
   try (TestDirectory dir = new TestDirectory("sdf2fasta")) {
     final File xd = new File(dir, "sdf");
     final ArrayList<InputStream> al = new ArrayList<>();
     al.add(
         new ByteArrayInputStream(
             ">test\nacgt\n>bob\ntagt\naccc\n>cat\ncat\n>dog\nccc".getBytes()));
     final FastaSequenceDataSource ds = new FastaSequenceDataSource(al, new DNAFastaSymbolTable());
     final SequencesWriter sw = new SequencesWriter(ds, xd, 300000, PrereadType.UNKNOWN, false);
     sw.processSequences();
     File x;
     SequencesReader sr = SequencesReaderFactory.createDefaultSequencesReader(xd);
     try {
       x = new File(dir, "junitmy.fasta");
       checkMainInitOk("-i", xd.toString(), "-o", x.toString(), "-Z");
       checkContent1(x);
     } finally {
       sr.close();
     }
     sr = SequencesReaderFactory.createDefaultSequencesReader(xd);
     try {
       checkMainInitOk("-i", xd.toString(), "-o", x.toString(), "-l", "3", "-Z");
       checkContent2(x);
     } finally {
       sr.close();
     }
   }
 }
 public void testInfo() throws IOException {
   // set a command line
   CommandLine.setCommandArgs("aksfj", "-d", "djfk siduf");
   try {
     final ArrayList<InputStream> al = new ArrayList<>();
     al.add(
         createStream(
             ">123456789012345678901\nacgtgtgtgtcttagggctcactggtcatgca\n>bob-the-builder\ntagttcagcatcgatca\n>hobos r us\naccccaccccacaaacccaa"));
     final FastaSequenceDataSource ds = new FastaSequenceDataSource(al, new DNAFastaSymbolTable());
     final SequencesWriter sw = new SequencesWriter(ds, mDir, 20, PrereadType.UNKNOWN, false);
     sw.setComment("wejksfd boier sakrjoieje");
     sw.processSequences();
     final CompressedMemorySequencesReader msr =
         (CompressedMemorySequencesReader)
             SequencesReaderFactory.createMemorySequencesReader(mDir, true, LongRange.NONE);
     checkDetails(msr);
     final CompressedMemorySequencesReader msr2 = (CompressedMemorySequencesReader) msr.copy();
     assertTrue(msr2 != msr);
     checkDetails(msr2);
     assertEquals("wejksfd boier sakrjoieje", msr.comment());
     assertEquals("wejksfd boier sakrjoieje", msr2.comment());
     assertEquals("aksfj -d \"djfk siduf\"", msr.commandLine());
     assertEquals("aksfj -d \"djfk siduf\"", msr2.commandLine());
   } finally {
     CommandLine.clearCommandArgs();
   }
 }
 /**
  * Alternative to other one with similar name
  *
  * @param directory directory containing SDF
  * @param indexFile index file
  * @param loadNames should we load names
  * @param loadFullNames should we load full names
  * @param region region to restrict to
  * @throws IOException IO exception occurs
  */
 CompressedMemorySequencesReader2(
     File directory,
     IndexFile indexFile,
     boolean loadNames,
     boolean loadFullNames,
     LongRange region)
     throws IOException {
   mIndexFile = indexFile;
   mRegion = SequencesReaderFactory.resolveRange(indexFile, region);
   mStart = mRegion.getStart();
   mEnd = mRegion.getEnd();
   mNumberSequences = mEnd - mStart;
   mData =
       DataInMemory.loadDelayQuality(
           directory,
           indexFile,
           DataFileIndex.loadSequenceDataFileIndex(indexFile.dataIndexVersion(), directory),
           mStart,
           mEnd);
   if (mNumberSequences > Integer.MAX_VALUE) {
     throw new IllegalArgumentException(
         "Too many sequences in region: " + region + ", maximum is: " + Integer.MAX_VALUE);
   }
   mDirectory = directory;
   if (loadNames && mIndexFile.hasNames()) {
     loadNames();
     loadNameSuffixes(loadFullNames, mIndexFile.hasSequenceNameSuffixes());
   }
   final StringBuilder sb = new StringBuilder("CMSR2 statistics");
   sb.append(LS);
   this.infoString(sb);
   Diagnostic.userLog(sb.toString());
 }
 public void testRoll() throws Exception {
   final ArrayList<InputStream> al = new ArrayList<>();
   al.add(
       createStream(
           ">123456789012345678901\nacgtgtgtgtcttagggctcactggtcatgca\n>bob the buuilder\ntagttcagcatcgatca\n>hobos r us\naccccaccccacaaacccaa"));
   final FastaSequenceDataSource ds = new FastaSequenceDataSource(al, new DNAFastaSymbolTable());
   final SequencesWriter sw = new SequencesWriter(ds, mDir, 20, PrereadType.UNKNOWN, false);
   sw.processSequences();
   try (SequencesReader dsr =
       SequencesReaderFactory.createMemorySequencesReader(mDir, true, LongRange.NONE)) {
     final SequencesIterator it = dsr.iterator();
     assertTrue(((CompressedMemorySequencesReader) dsr).integrity());
     assertEquals(mDir, dsr.path());
     assertTrue(it.nextSequence());
     assertEquals("1234567890123456789", it.currentName());
     assertEquals(32, it.currentLength());
     SequencesWriterTest.checkEquals(
         it,
         new byte[] {
           1, 2, 3, 4, 3, 4, 3, 4, 3, 4, 2, 4, 4, 1, 3, 3, 3, 2, 4, 2, 1, 2, 4, 3, 3, 4, 2, 1, 4,
           3, 2, 1
         });
     assertTrue(it.nextSequence());
     assertEquals("bob", it.currentName());
     assertEquals(17, it.currentLength());
     SequencesWriterTest.checkEquals(
         it, new byte[] {4, 1, 3, 4, 4, 2, 1, 3, 2, 1, 4, 2, 3, 1, 4, 2, 1});
     assertTrue(it.nextSequence());
     assertEquals("hobos", it.currentName());
     assertEquals(20, it.currentLength());
     SequencesWriterTest.checkEquals(
         it, new byte[] {1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 2, 1, 1});
   }
 }