Skip to content

Commit

Permalink
ready to open a pr
Browse files Browse the repository at this point in the history
  • Loading branch information
takutosato committed Aug 16, 2023
1 parent db71294 commit 583e0f3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
9 changes: 6 additions & 3 deletions src/main/java/htsjdk/samtools/SAMUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@

import htsjdk.samtools.seekablestream.SeekablePathStream;
import htsjdk.samtools.seekablestream.SeekableStream;
import htsjdk.samtools.util.*;
import htsjdk.samtools.util.BinaryCodec;
import htsjdk.samtools.util.CigarUtil;
import htsjdk.samtools.util.CloserUtil;
import htsjdk.samtools.util.CoordMath;
import htsjdk.samtools.util.RuntimeEOFException;
import htsjdk.samtools.util.StringUtil;
import htsjdk.tribble.annotation.Strand;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.nio.file.Path;
Expand Down Expand Up @@ -675,7 +679,6 @@ public static int combineMapqs(int m1, int m2) {

}

// tsato: to delete
public static long findVirtualOffsetOfFirstRecordInBam(final Path bamFile) {
try {
SeekableStream ss = new SeekablePathStream(bamFile);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/htsjdk/samtools/SamReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ public SAMRecord next() {
final SAMRecord previous = checker.getPreviousRecord();
if (!checker.isSorted(result)) {
throw new IllegalStateException(String.format(
"Record %s should come after %s when sorting with %s ordering.", // tsato: why doesn't this code get triggered when you have a bad sort order?
"Record %s should come after %s when sorting with %s ordering.",
previous.getSAMString().trim(),
result.getSAMString().trim(), checker.getSortOrder()));
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/htsjdk/samtools/filter/FilteringSamIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public class FilteringSamIterator implements CloseableIterator<SAMRecord> {
public FilteringSamIterator(final Iterator<SAMRecord> iterator, final SamRecordFilter filter,
final boolean filterByPair) {

if (filterByPair && iterator instanceof SAMRecordIterator) { // tsato: this whole thing has code smell
((SAMRecordIterator)iterator).assertSorted(SAMFileHeader.SortOrder.queryname); // tsato: wtf is this?
} // tsato: this does not throw an error here if the sort order is mismatched...bizarre.
if (filterByPair && iterator instanceof SAMRecordIterator) {
((SAMRecordIterator)iterator).assertSorted(SAMFileHeader.SortOrder.queryname);
}

this.iterator = new PeekableIterator<SAMRecord>(iterator);
this.filter = filter;
Expand Down Expand Up @@ -137,7 +137,7 @@ private SAMRecord getNextRecord() {
if (filterReadPairs && record.getReadPairedFlag() && record.getFirstOfPairFlag() &&
iterator.hasNext()) {

SamPairUtil.assertMate(record, iterator.peek()); // tsato: why is the code complaining?
SamPairUtil.assertMate(record, iterator.peek());

if (filter.filterOut(record, iterator.peek())) {
// skip second read
Expand All @@ -148,7 +148,7 @@ private SAMRecord getNextRecord() {
} else if (filterReadPairs && record.getReadPairedFlag() &&
record.getSecondOfPairFlag()) {
// assume that we did a pass(first, second) and it passed the filter
return record; // tsato: doesn't the first of pair always appear first if queryname sorted?
return record;
} else if (!filter.filterOut(record)) {
return record;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -704,13 +704,11 @@ static void readFully(SeekableByteChannel channel, ByteBuffer dst) throws IOExce
}
}

@Deprecated
public static void assertNonDefectiveFile(final File file) throws IOException {
if (checkTermination(file) == FileTermination.DEFECTIVE) {
throw new SAMException(file.getAbsolutePath() + " does not have a valid GZIP block at the end of the file.");
}
assertNonDefectivePath(file.toPath());
}

// tsato: can I consolidate with above?
public static void assertNonDefectivePath(final Path file) throws IOException {
if (checkTermination(file) == FileTermination.DEFECTIVE) {
throw new SAMException(file.toUri() + " does not have a valid GZIP block at the end of the file.");
Expand Down

0 comments on commit 583e0f3

Please sign in to comment.