merge from 2_4_Release branch
[jalview.git] / src / jalview / analysis / CrossRef.java
index 159d96a..8bc844b 100644 (file)
@@ -1,3 +1,21 @@
+/*\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4)\r
+ * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
+ * \r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * \r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ * GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA\r
+ */\r
 package jalview.analysis;\r
 \r
 import java.util.Enumeration;\r
@@ -158,7 +176,8 @@ public class CrossRef
       {\r
         if (cdna[c].getSource().equals(DBRefSource.EMBLCDS))\r
         {\r
-          System.err.println("TODO: unimplemented sequence retrieval for coding region sequence.");\r
+          System.err\r
+                  .println("TODO: unimplemented sequence retrieval for coding region sequence.");\r
           // TODO: retrieve CDS dataset sequences\r
           // need global dataset sequence retriever/resolver to reuse refs\r
           // and construct Mapping entry.\r
@@ -306,7 +325,10 @@ public class CrossRef
             xrfs = t;\r
             try\r
             {\r
-              retrieved = sftch.getSequences(xrfs); // problem here is we don't know which of xrfs resulted in which retrieved element\r
+              retrieved = sftch.getSequences(xrfs); // problem here is we don't\r
+                                                    // know which of xrfs\r
+                                                    // resulted in which\r
+                                                    // retrieved element\r
             } catch (Exception e)\r
             {\r
               System.err\r
@@ -319,32 +341,39 @@ public class CrossRef
               for (int rs = 0; rs < retrieved.length; rs++)\r
               {\r
                 // TODO: examine each sequence for 'redundancy'\r
-                jalview.datamodel.DBRefEntry[] dbr = retrieved[rs].getDBRef();\r
+                jalview.datamodel.DBRefEntry[] dbr = retrieved[rs]\r
+                        .getDBRef();\r
                 if (dbr != null && dbr.length > 0)\r
                 {\r
                   for (int di = 0; di < dbr.length; di++)\r
                   {\r
-                    // find any entry where we should put in the sequence being cross-referenced into the map\r
+                    // find any entry where we should put in the sequence being\r
+                    // cross-referenced into the map\r
                     jalview.datamodel.Mapping map = dbr[di].getMap();\r
                     if (map != null)\r
                     {\r
                       if (map.getTo() != null && map.getMap() != null)\r
                       {\r
-                        // should search the local dataset to find any existing candidates for To !\r
+                        // should search the local dataset to find any existing\r
+                        // candidates for To !\r
                         try\r
                         {\r
-                          // compare ms with dss and replace with dss in mapping if map is congruent\r
+                          // compare ms with dss and replace with dss in mapping\r
+                          // if map is congruent\r
                           SequenceI ms = map.getTo();\r
                           int sf = map.getMap().getToLowest();\r
                           int st = map.getMap().getToHighest();\r
                           SequenceI mappedrg = ms.getSubSequence(sf, st);\r
                           SequenceI loc = dss.getSubSequence(sf, st);\r
-                          if (mappedrg.getLength()>0 && mappedrg.getSequenceAsString().equals(\r
-                                  loc.getSequenceAsString()))\r
+                          if (mappedrg.getLength() > 0\r
+                                  && mappedrg.getSequenceAsString().equals(\r
+                                          loc.getSequenceAsString()))\r
                           {\r
                             System.err\r
                                     .println("Mapping updated for retrieved crossreference");\r
-                            // method to update all refs of existing To on retrieved sequence with dss and merge any props on To onto dss.\r
+                            // method to update all refs of existing To on\r
+                            // retrieved sequence with dss and merge any props\r
+                            // on To onto dss.\r
                             map.setTo(dss);\r
                           }\r
                         } catch (Exception e)\r
@@ -445,7 +474,7 @@ public class CrossRef
           boolean direct, boolean dna)\r
   {\r
     boolean found = false;\r
-    SequenceI[] typer=new SequenceI[1];\r
+    SequenceI[] typer = new SequenceI[1];\r
     if (dataset == null)\r
       return false;\r
     if (dataset.getSequences() == null)\r
@@ -470,7 +499,7 @@ public class CrossRef
           {\r
             typer[0] = nxt;\r
             boolean isDna = jalview.util.Comparison.isNucleotide(typer);\r
-            if ((direct && isDna == dna) || (!direct && isDna!=dna))\r
+            if ((direct && isDna == dna) || (!direct && isDna != dna))\r
             {\r
               // skip this sequence because it is same molecule type\r
               continue;\r
@@ -550,16 +579,17 @@ public class CrossRef
    *         System.out.println("Found " + ((prod == null) ? "no" : "" +\r
    *         prod.length) + " products"); if (prod!=null) { for (int p=0; p<prod.length;\r
    *         p++) { System.out.println("Prod "+p+":\r
-   *         "+prod[p].getDisplayId(true)); } } }\r
-   *  } else { System.out.println("Trying getProducts for\r
-   * "+al.getSequenceAt(0).getDisplayId(true)); System.out.println("Search DS\r
-   * Xref for: "+(dna ? "dna" : "prot")); // have a bash at finding the products\r
-   * amongst all the retrieved sequences. SequenceI[] prod =\r
-   * jalview.analysis.CrossRef.findXrefSequences(al .getSequencesArray(), dna,\r
-   * null, ds); System.out.println("Found " + ((prod == null) ? "no" : "" +\r
-   * prod.length) + " products"); if (prod!=null) { // select non-equivalent\r
-   * sequences from dataset list for (int p=0; p<prod.length; p++) {\r
-   * System.out.println("Prod "+p+": "+prod[p].getDisplayId(true)); } }\r
-   *  } }\r
+   *         "+prod[p].getDisplayId(true)); } } } } else {\r
+   *         System.out.println("Trying getProducts for\r
+   *         "+al.getSequenceAt(0).getDisplayId(true));\r
+   *         System.out.println("Search DS Xref for: "+(dna ? "dna" : "prot")); //\r
+   *         have a bash at finding the products amongst all the retrieved\r
+   *         sequences. SequenceI[] prod =\r
+   *         jalview.analysis.CrossRef.findXrefSequences(al\r
+   *         .getSequencesArray(), dna, null, ds); System.out.println("Found " +\r
+   *         ((prod == null) ? "no" : "" + prod.length) + " products"); if\r
+   *         (prod!=null) { // select non-equivalent sequences from dataset list\r
+   *         for (int p=0; p<prod.length; p++) { System.out.println("Prod\r
+   *         "+p+": "+prod[p].getDisplayId(true)); } } } }\r
    */\r
-}
\ No newline at end of file
+}\r