Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove redundant BAM file open in paired mode #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions src/umicollapse/main/DeduplicateSAM.java
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,14 @@ public int compareTo(Object o){
private static class Writer{
private boolean paired;
private SAMFileWriter writer;
private File in;
private SamReader reader;

private String ref = null;
private HashSet<ReversedRead> set;

public Writer(File in, File out, SamReader r, boolean paired){
if(paired){
this.in = in;
this.reader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).open(in);
this.set = new HashSet<ReversedRead>();
}

Expand Down Expand Up @@ -560,8 +561,14 @@ public void write(SAMRecord record){
}

public void close(){
if(paired)
if(paired) {
writeReversed(true);
try{
reader.close();
}catch(Exception e){
e.printStackTrace();
}
}

writer.close();
}
Expand All @@ -570,7 +577,6 @@ private void writeReversed(boolean fullPass){
if(ref == null)
return;

SamReader reader = SamReaderFactory.makeDefault().validationStringency(ValidationStringency.SILENT).open(in);
SAMRecordIterator iter = null;

if(fullPass)
Expand Down Expand Up @@ -598,11 +604,8 @@ private void writeReversed(boolean fullPass){
}
}

try{
reader.close();
}catch(Exception e){
e.printStackTrace();
}
iter.close();

}
}

Expand Down
Binary file modified umicollapse.jar
Binary file not shown.