JAL-3407 add and document ComputePeptideVariants.groovy
authorJim Procter <jprocter@issues.jalview.org>
Tue, 21 Apr 2020 16:39:33 +0000 (17:39 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Tue, 21 Apr 2020 16:39:33 +0000 (17:39 +0100)
examples/groovy/ComputePeptideVariants.groovy [new file with mode: 0644]
help/help/html/features/importvcf.html
help/help/html/releases.html
help/help/html/whatsNew.html

diff --git a/examples/groovy/ComputePeptideVariants.groovy b/examples/groovy/ComputePeptideVariants.groovy
new file mode 100644 (file)
index 0000000..6caa69c
--- /dev/null
@@ -0,0 +1,32 @@
+import jalview.datamodel.SequenceFeature
+import jalview.gui.Desktop
+def af = jalview.bin.Jalview.currentAlignFrame
+def av = af.viewport
+def fr = Desktop.getAlignFrameFor(av.codingComplement).getFeatureRenderer()
+def counts = 0
+def countm = 0
+for (seq in av.alignment.sequences) 
+{
+   ds = seq.datasetSequence
+   for (res = ds.start ; res <= ds.end; res++) 
+   {
+     mf = fr.findComplementFeaturesAtResidue(seq, res)
+     if (mf != null)
+     {
+         for (feature in mf.features)
+         {
+           variant = mf.findProteinVariants(feature)
+           if (!"".equals(variant))
+           {
+               type = variant.contains("=") ? "synonymous_variant" : "missense_variant"
+               if (type.equals("synonymous_variant")) counts++ else countm++;
+               sf = new SequenceFeature(type, variant, res, res, null)
+               seq.addSequenceFeature(sf)
+           }
+         }
+     }
+   }
+}
+af.getFeatureRenderer().featuresAdded()
+af.alignPanel.paintAlignment(true, true)
+println "Added " + countm + " missense and " + counts + " synonymous variants"
\ No newline at end of file
index 511ff2e..7b699eb 100755 (executable)
     for more information.
   </p>
   <p>
+    <strong>Working with variants without CSQ fields</strong>
+  </p>
+  <p>
+    <a name="computepepvariants">Jalview 2.11.1's new virtual
+      features</a> mean that peptide sequences are no longer annotated
+    directly with protein missense variants. This makes it harder to
+    filter variants when they do not already include the CSQ field. You
+    can rescue the pre-2.11.1 functionality by:
+  </p>
+  <ol>
+    <li>Download the script at
+      https://www.jalview.org/examples/groovy/ComputePeptideVariants.groovy</li>
+    <li>Executing the script via the <a href="groovy.html">Groovy
+        Console</a> on a linked CDS/Protein view to create missense and
+      synonymous peptide variant features.
+    </li>
+  </ol>
+  <p>
     <strong>Working with variants from organisms other than
       H.sapiens.</strong>
   </p>
index d3f2420..60e3179 100755 (executable)
@@ -139,6 +139,11 @@ li:before {
             to stdout containing the consensus sequence for each
             alignment in a Jalview session
           </li>
+          <li>
+            <!-- JAL-3578 -->ComputePeptideVariants.groovy to translate
+            genomic sequence_variant annotation from CDS as
+            missense_variant or synonymous_variant on protein products.
+          </li>
         </ul>
       </td>
       <td align="left" valign="top">
index 00f9466..0f0c7f1 100755 (executable)
       <a href="features/splitView.html#virtualfeats">Sequence
         Features dialog</a>. This allows more analyses of nucleotide and
       peptide sequence features on alignments in a more flexible and
-      memory efficient way than in earlier versions.</li>
+      memory efficient way than in earlier versions.<br />
+    <em>Note: Virtual features work best when variants are
+        annotated with CSQ fields. Please <a
+        href="features/importvcf.html#computepepvariants">see this
+          Groovy script workaround</a> if you are working with VCF files
+        without CSQ fields.
+    </em></li>
     <li><strong>Improved VCF data import</strong><br /> <a
       href="features/importvcf.html#attribs">Standard attributes for
         filtering variants</a> (e.g. position, QUAL field etc) are now