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
This commit is contained in:
ebanks 2010-06-16 19:37:09 +00:00
parent 01ffa307c2
commit f003703912
1 changed files with 16 additions and 0 deletions

View File

@ -73,11 +73,27 @@ public class SampleUtils {
* @return the set of unique samples
*/
public static Set<String> 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<String> getUniqueSamplesFromRods(GenomeAnalysisEngine toolkit, Set<String> rodNames) {
Set<String> samples = new TreeSet<String>();
// iterate to get all of the sample names
List<ReferenceOrderedDataSource> 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());