import jalview.util.MapList;
import jalview.util.MappingUtils;
import jalview.util.MessageManager;
+import jalview.util.StringUtils;
import java.io.File;
import java.io.IOException;
private Set<String> badData;
/**
- * Constructor given a VCF file
+ * Constructor given a path to a VCF file
*
- * @param alignment
+ * @param vcfFile
*/
public VCFLoader(String vcfFile)
{
}
/**
- * 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
{
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<String>) att).get(alleleIndex);
+ List<String> theList = (List<String>) att;
+ if (alleleIndex == -1)
+ {
+ result = StringUtils.listToDelimitedString(theList, ",");
+ }
+ else
+ {
+ result = theList.get(alleleIndex);
+ }
}
- return null;
+ return result;
}
/**
*/
index++;
}
+ else if (number == VCFHeaderLineCount.UNBOUNDED) // .
+ {
+ index = -1;
+ }
else if (number != VCFHeaderLineCount.A)
{
/*