X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2Fvcf%2FVCFLoader.java;h=1abe638517229ba40c740a542987159edbd34866;hb=refs%2Fheads%2Fspike%2Fclinvar;hp=d6a530b7956a086a11c8c8d406e65d0f8b088327;hpb=6875edc608179e9710388439099542296f263c15;p=jalview.git diff --git a/src/jalview/io/vcf/VCFLoader.java b/src/jalview/io/vcf/VCFLoader.java index d6a530b..1abe638 100644 --- a/src/jalview/io/vcf/VCFLoader.java +++ b/src/jalview/io/vcf/VCFLoader.java @@ -257,9 +257,9 @@ public class VCFLoader private Set badData; /** - * Constructor given a VCF file + * Constructor given a path to a VCF file * - * @param alignment + * @param vcfFile */ public VCFLoader(String vcfFile) { @@ -922,7 +922,11 @@ public class VCFLoader } /** - * A convenience method to get an attribute value for an alternate allele + * A convenience method to get an attribute value for an alternate allele. + * {@code alleleIndex} is the position in the list of values for the allele. + * If {@alleleIndex == -1} then all values are concatenated (comma-separated). + * This is the case for fields declared with "Number=." i.e. values are not + * related to specific alleles. * * @param variant * @param attributeName @@ -934,16 +938,25 @@ public class VCFLoader { Object att = variant.getAttribute(attributeName); + String result = null; if (att instanceof String) { - return (String) att; + result = (String) att; } - else if (att instanceof ArrayList) + else if (att instanceof List) { - return ((List) att).get(alleleIndex); + List theList = (List) att; + if (alleleIndex == -1) + { + result = StringUtils.listToDelimitedString(theList, ","); + } + else + { + result = theList.get(alleleIndex); + } } - return null; + return result; } /** @@ -1332,6 +1345,10 @@ public class VCFLoader */ index++; } + else if (number == VCFHeaderLineCount.UNBOUNDED) // . + { + index = -1; + } else if (number != VCFHeaderLineCount.A) { /*