JAL-2738 match consequence "Allele" to VCF allele; add non-SNP variants
[jalview.git] / src / jalview / analysis / AlignmentUtils.java
index c88a462..9a46a91 100644 (file)
@@ -2519,7 +2519,10 @@ public class AlignmentUtils
 
   /**
    * Builds a map whose key is position in the protein sequence, and value is a
-   * list of the base and all variants for each corresponding codon position
+   * list of the base and all variants for each corresponding codon position.
+   * <p>
+   * This depends on dna variants being held as a comma-separated list as
+   * property "alleles" on variant features.
    * 
    * @param dnaSeq
    * @param dnaToProtein
@@ -2559,18 +2562,26 @@ public class AlignmentUtils
       }
 
       /*
-       * extract dna variants to a string array
+       * ignore variant if not a SNP
        */
       String alls = (String) sf.getValue(Gff3Helper.ALLELES);
       if (alls == null)
       {
         continue; // non-SNP VCF variant perhaps - can't process this
       }
+
       String[] alleles = alls.toUpperCase().split(",");
-      int i = 0;
+      boolean isSnp = true;
       for (String allele : alleles)
       {
-        alleles[i++] = allele.trim(); // lose any space characters "A, G"
+        if (allele.trim().length() > 1)
+        {
+          isSnp = false;
+        }
+      }
+      if (!isSnp)
+      {
+        continue;
       }
 
       int[] mapsTo = dnaToProtein.locateInTo(dnaCol, dnaCol);