JAL-2738 ensure variant feature is in forward sense
[jalview.git] / src / jalview / io / vcf / VCFLoader.java
index a3e7e5a..3d269d8 100644 (file)
@@ -351,6 +351,9 @@ public class VCFLoader
     GeneLociI seqCoords = seq.getGeneLoci();
     if (seqCoords == null)
     {
+      System.out.println(String.format(
+              "Can't query VCF for %s as chromosome coordinates not known",
+              seq.getName()));
       return 0;
     }
 
@@ -429,27 +432,21 @@ public class VCFLoader
        */
       VariantContext variant = variants.next();
 
-      /*
-       * we can only process SNP variants (which can be reported
-       * as part of a MIXED variant record
-       */
-      if (!variant.isSNP() && !variant.isMixed())
-      {
-        // continue;
-      }
-
       int start = variant.getStart() - offset;
       int end = variant.getEnd() - offset;
 
       /*
        * convert chromosomal location to sequence coordinates
+       * - may be reverse strand (convert to forward for sequence feature)
        * - null if a partially overlapping feature
        */
       int[] seqLocation = mapping.locateInFrom(start, end);
       if (seqLocation != null)
       {
-        count += addAlleleFeatures(seq, variant, seqLocation[0],
-                seqLocation[1], forwardStrand);
+        int featureStart = Math.min(seqLocation[0], seqLocation[1]);
+        int featureEnd = Math.max(seqLocation[0], seqLocation[1]);
+        count += addAlleleFeatures(seq, variant, featureStart, featureEnd,
+                forwardStrand);
       }
     }
 
@@ -561,13 +558,6 @@ public class VCFLoader
     String reference = variant.getReference().getBaseString();
     Allele alt = variant.getAlternateAllele(altAlleleIndex);
     String allele = alt.getBaseString();
-    if (allele.length() != 1)
-    {
-      /*
-       * not a SNP variant
-       */
-      // return 0;
-    }
 
     /*
      * build the ref,alt allele description e.g. "G,A", using the base