Push 1793 latest to spike branch
[jalview.git] / src / jalview / io / vcf / VCFLoader.java
index a3e7e5a..e381b26 100644 (file)
@@ -287,7 +287,7 @@ public class VCFLoader
 
   /**
    * Transfers VCF features to sequences to which this sequence has a mapping.
-   * If the mapping is 1:3, computes peptide variants from nucleotide variants.
+   * If the mapping is 3:1, computes peptide variants from nucleotide variants.
    * 
    * @param seq
    */
@@ -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
@@ -865,7 +855,8 @@ public class VCFLoader
      * call (e.g.) http://rest.ensembl.org/map/human/GRCh38/17:45051610..45109016:1/GRCh37
      */
     EnsemblMap mapper = new EnsemblMap();
-    int[] mapping = mapper.getMapping(species, chromosome, fromRef, toRef,
+    int[] mapping = mapper.getAssemblyMapping(species, chromosome, fromRef,
+            toRef,
             queryRange);
 
     if (mapping == null)