From f00370391267704c91a4d6901b0f6e1773201ab4 Mon Sep 17 00:00:00 2001 From: ebanks Date: Wed, 16 Jun 2010 19:37:09 +0000 Subject: [PATCH] Allow specification of particular rods for pulling out sample names. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3570 348d0f76-0448-11de-a6fe-93d51630548a --- .../broadinstitute/sting/utils/SampleUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/java/src/org/broadinstitute/sting/utils/SampleUtils.java b/java/src/org/broadinstitute/sting/utils/SampleUtils.java index 0247e827b..31d106c53 100755 --- a/java/src/org/broadinstitute/sting/utils/SampleUtils.java +++ b/java/src/org/broadinstitute/sting/utils/SampleUtils.java @@ -73,11 +73,27 @@ public class SampleUtils { * @return the set of unique samples */ public static Set getUniqueSamplesFromRods(GenomeAnalysisEngine toolkit) { + return getUniqueSamplesFromRods(toolkit, null); + } + + /** + * Gets all of the unique sample names from the set of provided VCF rod names input by the user + * + * @param toolkit GATK engine + * @param rodNames list of rods to use; if null, uses all VCF rods + * + * @return the set of unique samples + */ + public static Set getUniqueSamplesFromRods(GenomeAnalysisEngine toolkit, Set rodNames) { Set samples = new TreeSet(); // iterate to get all of the sample names List dataSources = toolkit.getRodDataSources(); for ( ReferenceOrderedDataSource source : dataSources ) { + // ignore the rod if it's not in our list + if ( rodNames != null && !rodNames.contains(source.getName()) ) + continue; + RMDTrack rod = source.getReferenceOrderedData(); if ( rod.getRecordType().equals(VCFRecord.class) ) samples.addAll(rod.getHeader(VCFHeader.class).getGenotypeSamples());