Skip to content

Commit

Permalink
deprecating overloads makeCRAMWriter with mixed Path/File (#1150)
Browse files Browse the repository at this point in the history
* Deprecating overloads of SAMFileWriterFactory.makeCRAMWriter and .makeWriter that took a mix of Path and File as inputs.
  These were needed when we supported Path for the CRAM but not the reference.

* Removing one overload that seems redundant and hasn't been in any htsjdk release yet.
  • Loading branch information
lbergelson authored Jun 19, 2018
1 parent 72818a0 commit 96ce8fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
34 changes: 13 additions & 21 deletions src/main/java/htsjdk/samtools/SAMFileWriterFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public SAMFileWriter makeSAMOrBAMWriter(final SAMFileHeader header, final boolea
*
*/
public SAMFileWriter makeWriter(final SAMFileHeader header, final boolean presorted, final File outputFile, final File referenceFasta) {
return makeWriter(header, presorted, null == outputFile ? null : outputFile.toPath(), referenceFasta);
return makeWriter(header, presorted, null == outputFile ? null : outputFile.toPath(), null == referenceFasta ? null : referenceFasta.toPath());
}

/**
Expand All @@ -464,8 +464,9 @@ public SAMFileWriter makeWriter(final SAMFileHeader header, final boolean presor
* @param outputPath where to write the output. Must end with .sam, .bam or .cram.
* @param referenceFasta reference sequence file
* @return SAMFileWriter appropriate for the file type specified in outputPath
*
* @deprecated since 6/18, use {@link #makeWriter(SAMFileHeader, boolean, Path, Path)} instead
*/
@Deprecated
public SAMFileWriter makeWriter(final SAMFileHeader header, final boolean presorted, final Path outputPath, final File referenceFasta) {
return makeWriter(header, presorted, outputPath, null == referenceFasta ? null : referenceFasta.toPath());
}
Expand Down Expand Up @@ -550,9 +551,12 @@ public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final File outp
* @param referenceFasta reference sequence file
* @return CRAMFileWriter
*
* @deprecated since 6/18, prefer {@link #makeWriter(SAMFileHeader, boolean, Path, Path)} for creating bam/cram writers
* however {@link #makeCRAMWriter(SAMFileHeader, boolean, Path, Path)} is the direct replacement for this method
*/
@Deprecated
public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final Path outputPath, final File referenceFasta) {
return createCRAMWriterWithSettings(header, true, outputPath, null == referenceFasta ? null : referenceFasta.toPath());
return makeCRAMWriter(header, true, outputPath, null == referenceFasta ? null : referenceFasta.toPath());
}

/**
Expand All @@ -568,7 +572,7 @@ public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final Path outp
*
*/
public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final boolean presorted, final File outputFile, final File referenceFasta) {
return makeCRAMWriter(header, presorted, outputFile.toPath(), referenceFasta);
return makeCRAMWriter(header, presorted, outputFile.toPath(), null == referenceFasta ? null : referenceFasta.toPath());
}


Expand All @@ -583,25 +587,13 @@ public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final boolean p
* @param referenceFasta reference sequence file
* @return CRAMFileWriter
*
*/
public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final boolean presorted, final Path output, final File referenceFasta) {
return createCRAMWriterWithSettings(header, presorted, output, null == referenceFasta ? null : referenceFasta.toPath());
}

/**
* Create a CRAMFileWriter on an output file. Requires input record to be presorted to match the
* sort order defined by the input header.
*
* Note: does not honor factory settings for USE_ASYNC_IO.
*
* @param header entire header. Sort order is determined by the sortOrder property of this arg.
* @param outputPath where to write the output. Must end with .sam, .bam or .cram.
* @param referenceFasta reference sequence file
* @return CRAMFileWriter
* @deprecated since 6/18, prefer {@link #makeWriter(SAMFileHeader, boolean, Path, Path)} for creating bam/cram writers
* however {@link #makeCRAMWriter(SAMFileHeader, boolean, Path, Path)} is the direct replacement for this method
*
*/
public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final Path outputPath, final Path referenceFasta) {
return createCRAMWriterWithSettings(header, true, outputPath, referenceFasta);
@Deprecated
public CRAMFileWriter makeCRAMWriter(final SAMFileHeader header, final boolean presorted, final Path output, final File referenceFasta) {
return makeCRAMWriter(header, presorted, output, null == referenceFasta ? null : referenceFasta.toPath());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/htsjdk/samtools/CRAMComplianceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ private void writeRecordsToPath (
// tests to fail since it can change the order of some unmapped reads - this is allowed
// by the spec since the order is arbitrary for unmapped.
try (final SAMFileWriter writer = new SAMFileWriterFactory()
.makeWriter(samHeader, true, targetPath, referenceFile)) {
.makeWriter(samHeader, true, targetPath, referenceFile.toPath())) {
for (SAMRecord rec : recs) {
writer.addAlignment(rec);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public void testMakeWriterPath(String extension) throws Exception {
Files.deleteIfExists(outputPath);
final SAMFileHeader header = new SAMFileHeader();
final SAMFileWriterFactory factory = createWriterFactoryWithOptions(header);
final File referenceFile = new File(TEST_DATA_DIR, "hg19mini.fasta");
final Path referenceFile = new File(TEST_DATA_DIR, "hg19mini.fasta").toPath();

int nRecs;
try (final SAMFileWriter samWriter = factory.makeWriter(header, false, outputPath, referenceFile)) {
Expand Down

0 comments on commit 96ce8fb

Please sign in to comment.