Search in sources :

Example 1 with ComputeSamTags

use of gridss.ComputeSamTags in project gridss by PapenfussLab.

the class StaticDeBruijnPathGraphGexfExporterTest method add_tags.

// @Test
// @Ignore("Once-off data import")
public void add_tags() throws IOException {
    File in = new File("src/test/resources/chr12-244000.bam");
    File insq = new File("src/test/resources/chr12-244000.sq.bam");
    File outsq = new File("src/test/resources/chr12-244000.sq.tagged.bam");
    File out = new File("src/test/resources/chr12-244000.tagged.bam");
    SAMFileUtil.sort(getFSContext(), in, insq, SortOrder.queryname);
    File ref = Hg19Tests.findHg19Reference("chr12.fa");
    ComputeSamTags cmd = new ComputeSamTags();
    cmd.instanceMain(new String[] { "INPUT=" + insq.getAbsolutePath(), "OUTPUT=" + outsq.getAbsolutePath(), "REFERENCE_SEQUENCE=" + ref.getAbsolutePath() });
    SAMFileUtil.sort(getFSContext(), outsq, out, SortOrder.coordinate);
}
Also used : ComputeSamTags(gridss.ComputeSamTags) File(java.io.File)

Example 2 with ComputeSamTags

use of gridss.ComputeSamTags in project gridss by PapenfussLab.

the class SAMEvidenceSource method ensureExtracted.

public void ensureExtracted() throws IOException {
    File svFile = getContext().getFileSystemContext().getSVBam(getFile());
    File extractedFile = FileSystemContext.getWorkingFileFor(svFile, "gridss.tmp.extracted.");
    File querysortedFile = FileSystemContext.getWorkingFileFor(svFile, "gridss.tmp.querysorted.");
    File taggedFile = FileSystemContext.getWorkingFileFor(svFile, "gridss.tmp.tagged.");
    File withsplitreadsFile = FileSystemContext.getWorkingFileFor(svFile, "gridss.tmp.splitreads.");
    ensureMetrics();
    // have the same tags
    if (!svFile.exists()) {
        if (!withsplitreadsFile.exists()) {
            if (!taggedFile.exists()) {
                if (!querysortedFile.exists()) {
                    if (!extractedFile.exists()) {
                        log.info("Extracting SV reads from " + getFile().getAbsolutePath());
                        File in = getFile(SortOrder.queryname);
                        if (in == null || !in.exists()) {
                            in = getFile();
                        }
                        List<String> args = Lists.newArrayList("INPUT=" + in.getAbsolutePath(), "OUTPUT=" + extractedFile.getAbsolutePath(), // saves intermediate file space
                        "UNMAPPED_READS=false", "METRICS_OUTPUT=" + getContext().getFileSystemContext().getSVMetrics(getFile()), "MIN_CLIP_LENGTH=" + getContext().getConfig().getSoftClip().minLength, "READ_PAIR_CONCORDANCE_METHOD=" + rpcMethod.name(), "FIXED_READ_PAIR_CONCORDANCE_MIN_FRAGMENT_SIZE=" + rpcMinFragmentSize, "FIXED_READ_PAIR_CONCORDANCE_MAX_FRAGMENT_SIZE=" + rpcMaxFragmentSize, "READ_PAIR_CONCORDANT_PERCENT=" + rpcConcordantPercentage, "INSERT_SIZE_METRICS=" + getContext().getFileSystemContext().getInsertSizeMetrics(getFile()));
                        execute(new ExtractSVReads(), args);
                    }
                    SAMFileUtil.sort(getContext().getFileSystemContext(), extractedFile, querysortedFile, SortOrder.queryname);
                    if (gridss.Defaults.DELETE_TEMPORARY_FILES) {
                        FileHelper.delete(extractedFile, true);
                    }
                }
                log.info("Computing SAM tags for " + svFile);
                List<String> args = Lists.newArrayList("INPUT=" + querysortedFile.getAbsolutePath(), "OUTPUT=" + taggedFile.getAbsolutePath());
                execute(new ComputeSamTags(), args);
                if (gridss.Defaults.DELETE_TEMPORARY_FILES) {
                    FileHelper.delete(querysortedFile, true);
                }
            }
            log.info("Identifying split reads for " + getFile().getAbsolutePath());
            List<String> args = Lists.newArrayList("WORKER_THREADS=" + getProcessContext().getWorkerThreadCount(), "INPUT=" + taggedFile.getAbsolutePath(), "OUTPUT=" + withsplitreadsFile.getAbsolutePath());
            // realignment.* not soft-clip
            // "MIN_CLIP_LENGTH=" + getContext().getConfig().
            // "MIN_CLIP_QUAL=" + getContext().getConfig().getSoftClip().minAverageQual);
            execute(new SoftClipsToSplitReads(), args);
            if (gridss.Defaults.DELETE_TEMPORARY_FILES) {
                FileHelper.delete(taggedFile, true);
            }
        }
        SAMFileUtil.sort(getContext().getFileSystemContext(), withsplitreadsFile, svFile, SortOrder.coordinate);
        if (gridss.Defaults.DELETE_TEMPORARY_FILES) {
            FileHelper.delete(withsplitreadsFile, true);
        }
    }
    if (gridss.Defaults.DELETE_TEMPORARY_FILES) {
        FileHelper.delete(extractedFile, true);
        FileHelper.delete(querysortedFile, true);
        FileHelper.delete(taggedFile, true);
        FileHelper.delete(withsplitreadsFile, true);
    }
}
Also used : ComputeSamTags(gridss.ComputeSamTags) MetricsFile(htsjdk.samtools.metrics.MetricsFile) File(java.io.File) ExtractSVReads(gridss.ExtractSVReads) SoftClipsToSplitReads(gridss.SoftClipsToSplitReads)

Aggregations

ComputeSamTags (gridss.ComputeSamTags)2 File (java.io.File)2 ExtractSVReads (gridss.ExtractSVReads)1 SoftClipsToSplitReads (gridss.SoftClipsToSplitReads)1 MetricsFile (htsjdk.samtools.metrics.MetricsFile)1