Merge remote-tracking branch 'origin/bug/JAL-3082selectRegex' into merge/JAL-3082
[jalview.git] / src / jalview / io / vcf / VCFLoader.java
index 9addfaa..5ba5d93 100644 (file)
@@ -835,33 +835,6 @@ public class VCFLoader
   }
 
   /**
-   * A convenience method to get the AF value for the given alternate allele
-   * index
-   * 
-   * @param variant
-   * @param alleleIndex
-   * @return
-   */
-  protected float getAlleleFrequency(VariantContext variant, int alleleIndex)
-  {
-    float score = 0f;
-    String attributeValue = getAttributeValue(variant,
-            ALLELE_FREQUENCY_KEY, alleleIndex);
-    if (attributeValue != null)
-    {
-      try
-      {
-        score = Float.parseFloat(attributeValue);
-      } catch (NumberFormatException e)
-      {
-        // leave as 0
-      }
-    }
-
-    return score;
-  }
-
-  /**
    * A convenience method to get an attribute value for an alternate allele
    * 
    * @param variant
@@ -981,10 +954,8 @@ public class VCFLoader
       type = getOntologyTerm(consequence);
     }
 
-    float score = getAlleleFrequency(variant, altAlleleIndex);
-
     SequenceFeature sf = new SequenceFeature(type, alleles, featureStart,
-            featureEnd, score, FEATURE_GROUP_VCF);
+            featureEnd, FEATURE_GROUP_VCF);
     sf.setSource(sourceId);
 
     sf.setValue(Gff3Helper.ALLELES, alleles);
@@ -1013,6 +984,10 @@ public class VCFLoader
   {
     String type = SequenceOntologyI.SEQUENCE_VARIANT;
 
+    /*
+     * could we associate Consequence data with this allele and feature (transcript)?
+     * if so, prefer the consequence term from that data
+     */
     if (csqAlleleFieldIndex == -1) // && snpEffAlleleFieldIndex == -1
     {
       /*
@@ -1021,10 +996,6 @@ public class VCFLoader
       return type;
     }
 
-    /*
-     * can we associate Consequence data with this allele and feature (transcript)?
-     * if so, prefer the consequence term from that data
-     */
     if (consequence != null)
     {
       String[] csqFields = consequence.split(PIPE_REGEX);
@@ -1190,6 +1161,14 @@ public class VCFLoader
       }
 
       /*
+       * filter out fields we don't want to capture
+       */
+      if (!vcfFieldsOfInterest.contains(key))
+      {
+        continue;
+      }
+
+      /*
        * we extract values for other data which are allele-specific; 
        * these may be per alternate allele (INFO[key].Number = 'A') 
        * or per allele including reference (INFO[key].Number = 'R') 
@@ -1249,7 +1228,6 @@ public class VCFLoader
           String myConsequence)
   {
     Object value = variant.getAttribute(CSQ_FIELD);
-    // TODO if CSQ not present, try ANN (for SnpEff consequence data)?
 
     if (value == null || !(value instanceof List<?>))
     {