Skip to content

Commit

Permalink
fix: use getBestAvailableSequenceDictionary()
Browse files Browse the repository at this point in the history
  • Loading branch information
sanashah007 committed Aug 13, 2024
1 parent 829b8f3 commit 6c8f3dc
Showing 1 changed file with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package org.broadinstitute.hellbender.tools.walkers.conversion;

import htsjdk.samtools.SAMSequenceDictionary;
import htsjdk.samtools.SamReader;
import htsjdk.samtools.SamReaderFactory;
import htsjdk.samtools.util.*;
import htsjdk.tribble.Feature;
import org.apache.log4j.LogManager;
Expand All @@ -18,7 +16,6 @@
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.codecs.gtf.GencodeGtfFeature;

import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
Expand Down Expand Up @@ -82,7 +79,6 @@
@WorkflowProperties
public class GtfToBed extends FeatureWalker<GencodeGtfFeature> {
public static final String SORT_BY_TRANSCRIPT_LONG_NAME = "sort-transcript";
public static final String SEQUENCE_DICTIONARY_LONG_NAME = "gtf-dictionary";
public static final String SORT_BY_BASIC_LONG_NAME = "sort-basic";
public static final String INPUT_LONG_NAME = "gtf-path";
protected final Logger logger = LogManager.getLogger(this.getClass());
Expand All @@ -96,10 +92,7 @@ public class GtfToBed extends FeatureWalker<GencodeGtfFeature> {
@Argument(fullName = SORT_BY_TRANSCRIPT_LONG_NAME, doc = "Make each row of BED file sorted by transcript", optional = true)
public boolean sortByTranscript = false;

@Argument( fullName = SEQUENCE_DICTIONARY_LONG_NAME, doc = "Path to sequence dictionary")
public GATKPath sequenceDictionary;

@Argument( fullName = SORT_BY_BASIC_LONG_NAME, doc = "Only use basic transcripts")
@Argument(fullName = SORT_BY_BASIC_LONG_NAME, doc = "Only use basic transcripts")
public boolean sortByBasic = false;

//stores either gene or transcript ID and summary information about the feature
Expand Down Expand Up @@ -219,8 +212,9 @@ private void updateGeneInterval(GencodeGtfFeature gtfFeature, int geneStart, int
// runs immediately after it has gone through each line of gtf (apply method)
@Override
public Object onTraversalSuccess() {
// get the user input dictionary
SAMSequenceDictionary sequenceDictionary = getSequenceDictionary(String.valueOf(this.sequenceDictionary));
// get dictionary
SAMSequenceDictionary sequenceDictionary = getBestAvailableSequenceDictionary();


// create linked hash map to store sorted values of idToInfo
LinkedHashMap<String, GtfInfo> karyotypeIdToInfo = getSortedMap(sequenceDictionary);
Expand All @@ -232,13 +226,6 @@ public Object onTraversalSuccess() {
return null;
}

// reads the dictionary
private SAMSequenceDictionary getSequenceDictionary(String dictionaryPath) {
SamReader reader = SamReaderFactory.makeDefault().open(new File(dictionaryPath));

return reader.getFileHeader().getSequenceDictionary();
}

//Compare GtfInfo objects positionally by contig and start position. If transcripts have the same contig and start, compare by TranscriptId
public static class GtfInfoComparator implements Comparator<Map.Entry<String, GtfInfo>> {

Expand Down

0 comments on commit 6c8f3dc

Please sign in to comment.