From 9445326c6cbcc68fc46f8109d2e173824197706c Mon Sep 17 00:00:00 2001 From: Mark DePristo Date: Sun, 20 Nov 2011 18:26:27 -0500 Subject: [PATCH] Genotype is Comparable via sampleName --- build.xml | 4 ++-- .../sting/utils/variantcontext/Genotype.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/build.xml b/build.xml index 232b074f6..66d99ac67 100644 --- a/build.xml +++ b/build.xml @@ -927,8 +927,8 @@ - - + + diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/Genotype.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/Genotype.java index b100d6da5..1691129c9 100755 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/Genotype.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/Genotype.java @@ -12,7 +12,7 @@ import java.util.*; * * @author Mark DePristo */ -public class Genotype { +public class Genotype implements Comparable { public final static String PHASED_ALLELE_SEPARATOR = "|"; public final static String UNPHASED_ALLELE_SEPARATOR = "/"; @@ -351,4 +351,14 @@ public class Genotype { public int getAttributeAsInt(String key, int defaultValue) { return commonInfo.getAttributeAsInt(key, defaultValue); } public double getAttributeAsDouble(String key, double defaultValue) { return commonInfo.getAttributeAsDouble(key, defaultValue); } public boolean getAttributeAsBoolean(String key, boolean defaultValue) { return commonInfo.getAttributeAsBoolean(key, defaultValue); } + + /** + * comparable genotypes -> compareTo on the sample names + * @param genotype + * @return + */ + @Override + public int compareTo(final Genotype genotype) { + return getSampleName().compareTo(genotype.getSampleName()); + } } \ No newline at end of file