Skip to content

Commit

Permalink
Bugfix to UpdateReadsetFilesHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
bbimber committed Aug 20, 2024
1 parent 075a2ee commit 0b52dce
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.labkey.sequenceanalysis.analysis;

import com.google.common.io.Files;
import htsjdk.samtools.SAMFileHeader;
import htsjdk.samtools.SAMFileWriter;
import htsjdk.samtools.SAMFileWriterFactory;
Expand Down Expand Up @@ -111,6 +112,10 @@ else if (SequenceUtil.FILETYPE.gvcf.getFileType().isType(so.getFile()) | Sequenc
{
getAndValidateHeaderForVcf(so, newRsName);
}
else
{
throw new PipelineJobException("Unexpected file type: " + so.getFile().getPath());
}

ctx.getSequenceSupport().cacheObject("readsetId", newRsName);
}
Expand Down Expand Up @@ -207,6 +212,18 @@ private void reheaderVcf(SequenceOutputFile so, JobContext ctx, String newRsName
String existingSample = header.getGenotypeSamples().get(0);

File sampleNamesFile = new File(ctx.getWorkingDirectory(), "sampleNames.txt");
if (!sampleNamesFile.exists())
{
try
{
Files.touch(sampleNamesFile);
}
catch (IOException e)
{
throw new PipelineJobException(e);
}
}

try (PrintWriter writer = PrintWriters.getPrintWriter(sampleNamesFile, StandardOpenOption.APPEND))
{
writer.println(newRsName);
Expand Down Expand Up @@ -243,6 +260,11 @@ private void addTracker(SequenceOutputFile so, String existingSample, String new
{
File tracker = new File(so.getFile().getParentFile(), "reheaderHistory.txt");
boolean preExisting = tracker.exists();
if (!preExisting)
{
Files.touch(tracker);
}

try (PrintWriter writer = PrintWriters.getPrintWriter(tracker, StandardOpenOption.APPEND))
{
if (!preExisting)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public void init(SequenceOutputHandler.JobContext ctx, List<SequenceOutputFile>
{
if (!LOUPE_TYPE.isType(so.getFile()))
{
if (!so.getFile().getName().endsWith("seurat.rds"))
{
throw new PipelineJobException("Unexpected file type: " + so.getFile().getPath());
}

File meta = new File(so.getFile().getPath().replaceAll(".seurat.rds", ".cellBarcodes.csv"));
if (!meta.exists())
{
Expand Down

0 comments on commit 0b52dce

Please sign in to comment.