Skip to content

Commit

Permalink
responding to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lbergelson committed Oct 15, 2018
1 parent 4cf7ce9 commit 39c0997
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/java/htsjdk/samtools/CRAMIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public boolean hasNext() {

@Override
public SAMRecord next() {
if(hasNext()) {
if (hasNext()) {
return iterator.next();
} else {
throw new NoSuchElementException();
Expand Down
18 changes: 10 additions & 8 deletions src/test/java/htsjdk/samtools/CRAMTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

public final class CRAMTestUtils {

//private constructor since this is a utility class
private CRAMTestUtils(){};

/**
Expand All @@ -40,21 +41,22 @@ public static CRAMFileReader writeAndReadFromInMemoryCram(SAMRecordSetBuilder re
}

private static CRAMFileReader writeAndReadFromInMemoryCram(Collection<SAMRecord> records, CRAMReferenceSource source, SAMFileHeader header) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
CRAMFileWriter cramFileWriter = new CRAMFileWriter(baos, source, header, "whatever");
try(ByteArrayOutputStream baos = new ByteArrayOutputStream();
CRAMFileWriter cramFileWriter = new CRAMFileWriter(baos, source, header, "whatever")){

for (SAMRecord record : records) {
cramFileWriter.addAlignment(record);
}
cramFileWriter.close();
records.forEach(cramFileWriter::addAlignment);

//force a flush before reading from the buffer
cramFileWriter.close();

return new CRAMFileReader(new ByteArrayInputStream(baos.toByteArray()), (SeekableStream) null, source, ValidationStringency.SILENT);
return new CRAMFileReader(new ByteArrayInputStream(baos.toByteArray()), (SeekableStream) null, source, ValidationStringency.SILENT);
}
}

/**
* return a CRAMReferenceSource that returns all A's for any sequence queried
*/
public static CRAMReferenceSource getFakeReferenceSource(){
public static CRAMReferenceSource getFakeReferenceSource() {
return (sequenceRecord, tryNameVariants) -> {
byte[] bases = new byte[sequenceRecord.getSequenceLength()];
Arrays.fill(bases, (byte)'A');
Expand Down

0 comments on commit 39c0997

Please sign in to comment.