groovy scripting examples (JAL-???)
[jalview.git] / examples / groovy / removeFeaturesByGroup.groovy
diff --git a/examples/groovy/removeFeaturesByGroup.groovy b/examples/groovy/removeFeaturesByGroup.groovy
new file mode 100644 (file)
index 0000000..bf7f74d
--- /dev/null
@@ -0,0 +1,31 @@
+import jalview.analysis.*;
+import jalview.datamodel.*;
+import jalview.gui.AlignFrame;
+import jalview.gui.AlignViewport;
+
+def af = Jalview.getAlignframes();
+
+def todie = "PDBFile"; // about to delete this type of group
+for (ala in af)
+{
+       def al = ala.viewport.alignment.getDataset();
+       if (al!=null)
+       {
+               SequenceI[] seqs = al.getSequencesArray();
+               for (sq in seqs)
+               {
+                       if (sq!=null) {
+                               SequenceFeature[] sf = sq.getSequenceFeatures();
+                               for (sfpos in sf)
+                               {
+                                   if (sfpos!=null && sfpos.getFeatureGroup().equals(todie))
+                                       {
+                                               sq.deleteFeature(sfpos);
+                                       }
+                               }
+                       }
+               }
+       }
+}
+       
+