JAL-1466 flag and jalview_properties setting to control retrieval of full length...
authorJim Procter <jprocter@dundee.ac.uk>
Fri, 18 Apr 2014 09:12:40 +0000 (10:12 +0100)
committerJim Procter <jprocter@dundee.ac.uk>
Mon, 21 Apr 2014 13:09:17 +0000 (14:09 +0100)
resources/lang/Messages.properties
src/jalview/gui/AlignFrame.java
src/jalview/ws/DBRefFetcher.java

index 769718a..ce534e1 100644 (file)
@@ -724,4 +724,5 @@ label.wswublast_client_credits = To display sequence features an exact Uniprot i
 label.blasting_for_unidentified_sequence = BLASTing for unidentified sequences
 label.select_columns_containing = Select columns containing\r
 label.select_columns_not_containing = Select columns that do not contain\r
-\r
+option.trim_retrieved_seqs = Trim retrieved sequences\r
+label.trim_retrieved_sequences = When the reference sequence is longer than the sequence that you are working with, only keep the relevant subsequences.\r
index f7e95b7..3f9ebaf 100644 (file)
@@ -118,6 +118,7 @@ import java.util.List;
 import java.util.Vector;
 
 import javax.swing.JButton;
+import javax.swing.JCheckBoxMenuItem;
 import javax.swing.JEditorPane;
 import javax.swing.JInternalFrame;
 import javax.swing.JLabel;
@@ -5198,6 +5199,17 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
     rfetch.setToolTipText(MessageManager.getString("label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences"));\r
     webService.add(rfetch);
 
+    final JCheckBoxMenuItem trimrs = new JCheckBoxMenuItem(MessageManager.getString("option.trim_retrieved_seqs"));
+    trimrs.setToolTipText(MessageManager.getString("label.trim_retrieved_sequences"));
+    trimrs.setSelected(Cache.getDefault("TRIM_FETCHED_DATASET_SEQS", true));
+    trimrs.addActionListener(new ActionListener()
+    {
+      public void actionPerformed(ActionEvent e) {
+      trimrs.setSelected(trimrs.isSelected());
+      Cache.setProperty("TRIM_FETCHED_DATASET_SEQS", Boolean.valueOf(trimrs.isSelected()).toString());
+    };
+    });
+    rfetch.add(trimrs);
     JMenuItem fetchr = new JMenuItem(MessageManager.getString("label.standard_databases"));\r
     fetchr.setToolTipText(MessageManager.getString("label.fetch_embl_uniprot"));\r
     fetchr.addActionListener(new ActionListener()
index 9742bca..a156b2c 100644 (file)
@@ -78,6 +78,11 @@ public class DBRefFetcher implements Runnable
 
   private SequenceI[] alseqs;
 
+  /**
+   * when true - retrieved sequences will be trimmed to cover longest derived alignment sequence 
+   */
+  private boolean trimDsSeqs=true;
+
   public DBRefFetcher()
   {
   }
@@ -124,6 +129,8 @@ public class DBRefFetcher implements Runnable
     this.dataset = ds;
     // TODO Jalview 2.5 lots of this code should be in the gui package!
     sfetcher = jalview.gui.SequenceFetcher.getSequenceFetcherSingleton(af);
+    // set default behaviour for transferring excess sequence data to the dataset 
+    trimDsSeqs = Cache.getDefault("TRIM_FETCHED_DATASET_SEQS", true);
     if (sources == null)
     {
       // af.featureSettings_actionPerformed(null);
@@ -372,7 +379,7 @@ public class DBRefFetcher implements Runnable
             if (retrieved != null)
             {
               transferReferences(sdataset, dbsource.getDbSource(),
-                      retrieved);
+                      retrieved,trimDsSeqs);
             }
           }
           else
@@ -469,12 +476,14 @@ public class DBRefFetcher implements Runnable
   /**
    * Verify local sequences in seqRefs against the retrieved sequence database
    * records.
+   * @param trimDatasetSeqs 
    * 
    */
   void transferReferences(Vector sdataset, String dbSource,
-          AlignmentI retrievedAl) // File
+          AlignmentI retrievedAl, boolean trimDatasetSeqs) // File
   // file)
   {
+    System.out.println("trimming ? "+trimDatasetSeqs);
     if (retrievedAl == null || retrievedAl.getHeight() == 0)
     {
       return;