Skip to content

Commit

Permalink
Addressed PR comment
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTL1220 committed Jun 8, 2018
1 parent 76178df commit 30f7ad3
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class FuncotationMap {
/** Standard Logger. */
protected static final Logger logger = LogManager.getLogger(FuncotationMap.class);


final private Map<String, LinkedHashSet<Funcotation>> txToFuncotations = new LinkedHashMap<>();

private FuncotationMap() {}
Expand Down Expand Up @@ -166,6 +165,15 @@ public List<String> getTranscriptList() {
return new ArrayList<>(txToFuncotations.keySet());
}

/**
* Get the transcripts as a of transcripts in order.
*
* @return Never {@code null}
*/
public LinkedHashSet<String> getTranscriptSet() {
return new LinkedHashSet<>(txToFuncotations.keySet());
}

/** Create a FuncotationMap where all Funcotations will be TableFuncotations. This is useful for parsing existing
* VCFs.
* Only renders for a single allele.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.broadinstitute.hellbender.exceptions.GATKException;
import org.broadinstitute.hellbender.tools.funcotator.dataSources.TableFuncotation;
import org.broadinstitute.hellbender.tools.funcotator.dataSources.gencode.GencodeFuncotation;
import org.broadinstitute.hellbender.tools.funcotator.dataSources.gencode.GencodeFuncotationBuilder;
import org.broadinstitute.hellbender.tools.funcotator.dataSources.gencode.GencodeFuncotationFactory;
import org.broadinstitute.hellbender.utils.SimpleInterval;
import org.broadinstitute.hellbender.utils.codecs.gencode.GencodeGtfCodec;
Expand Down Expand Up @@ -513,4 +514,36 @@ public void testCreateNoTranscriptInfo(final List<Funcotation> funcotations) {
Assert.assertEquals(funcotationMap.getGencodeFuncotations(FuncotationMap.NO_TRANSCRIPT_AVAILABLE_KEY).size(), 0);
}

@DataProvider
public Object[][] provideFakeGencodeData() {

return new Object[][] {
{Collections.singletonList(new GencodeFuncotationBuilder().setAnnotationTranscript("TXID").build())},
{Arrays.asList(new GencodeFuncotationBuilder().setAnnotationTranscript("TXID1").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID2").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID3").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID4").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID5").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID6").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID7").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID8").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID9").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID10").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID11").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID12").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID13").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID14").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID15").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID16").build(),
new GencodeFuncotationBuilder().setAnnotationTranscript("TXID17").build())
}
};
}

@Test(dataProvider = "provideFakeGencodeData")
public void testTranscriptListAndSetAreOrdered(final List<GencodeFuncotation> gencodeFuncotations) {
// Tests that both the list and the set are ordered the same way and produce equals values.
final FuncotationMap funcotationMap = FuncotationMap.createFromGencodeFuncotations(gencodeFuncotations);
Assert.assertEquals(funcotationMap.getTranscriptList(), new ArrayList<>(funcotationMap.getTranscriptSet()));
}
}

0 comments on commit 30f7ad3

Please sign in to comment.