refactored das sequence source creation code to the implementor of the das source...
[jalview.git] / examples / groovy / stripUniprotPrefixes.groovy
1 import jalview.analysis.*;
2 import jalview.datamodel.*;
3 import jalview.gui.AlignFrame;
4 import jalview.gui.AlignViewport;
5
6 def af = Jalview.getAlignframes();
7
8 // walk through  all alignments, stripping off all text prior to and including last '|' symbol in sequence IDs
9
10 for (ala in af)
11 {
12         def al = ala.viewport.alignment;
13         if (al!=null)
14         {
15                 SequenceI[] seqs = al.getSequencesArray();
16                 for (sq in seqs)
17                 {
18                         if (sq!=null) {
19                                 if (sq.getName().indexOf("|")>-1)
20                                 {
21                                         sq.setName(sq.getName().substring(sq.getName().lastIndexOf("|")+1));
22                                         if (sq.getDatasetSequence()!=null)
23                                         {
24                                                 sq.getDatasetSequence().setName(sq.getName());
25                                         }
26                                 }
27                         }
28                 }
29         }
30 }
31