From 41392f8ff531fd1a2e4e404ce3f6b9d6f8c7acdc Mon Sep 17 00:00:00 2001 From: depristo Date: Sat, 16 Jan 2010 20:19:43 +0000 Subject: [PATCH] functions for setting gentoype records and alternate bases; function for getting all rods implementing VCF git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2611 348d0f76-0448-11de-a6fe-93d51630548a --- .../sting/utils/genotype/vcf/VCFRecord.java | 14 +++++++++++++- .../sting/utils/genotype/vcf/VCFUtils.java | 12 ++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java index e24245fd5..439e2a257 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFRecord.java @@ -283,7 +283,7 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { } public VARIANT_TYPE getType() { - if ( !hasAlternateAllele() ) + if ( ! hasAlternateAllele() ) return VARIANT_TYPE.REFERENCE; VCFGenotypeEncoding.TYPE type = mAlts.get(0).getType(); @@ -479,6 +479,12 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { mGenotypeRecords.add(mGenotypeRecord); } + public void setGenotypeRecords(List records) { + mGenotypeRecords.clear(); + for ( VCFGenotypeRecord g : records ) + addGenotypeRecord(g); + } + /** * add an alternate base to our alternate base list. All bases are uppercased * before being added to the list. @@ -489,6 +495,12 @@ public class VCFRecord implements Variation, VariantBackedByGenotype { if (!mAlts.contains(base)) mAlts.add(base); } + public void setAlternateBases(List bases) { + mAlts.clear(); + for ( VCFGenotypeEncoding e : bases ) + addAlternateBase(e); + } + /** * add an info field to the record * diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java index 46d7de6ac..0ef038ba6 100755 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFUtils.java @@ -19,6 +19,18 @@ public class VCFUtils { */ private VCFUtils() { } + public static Set getRodVCFs(GenomeAnalysisEngine toolkit) { + Set vcfs = new HashSet(); + + for ( ReferenceOrderedDataSource source : toolkit.getRodDataSources() ) { + ReferenceOrderedData rod = source.getReferenceOrderedData(); + if ( rod.getType().equals(RodVCF.class) ) { + vcfs.add(rod); + } + } + + return vcfs; + } /** * Gets the header fields from all VCF rods input by the user