fix occasional nullpointer ref when seq ID retrieval doesn't resolve to a sequence...
authorjprocter <Jim Procter>
Fri, 6 Feb 2009 14:56:21 +0000 (14:56 +0000)
committerjprocter <Jim Procter>
Fri, 6 Feb 2009 14:56:21 +0000 (14:56 +0000)
src/jalview/analysis/CrossRef.java

index 8bc844b..ffda7f2 100644 (file)
@@ -104,36 +104,41 @@ public class CrossRef
     Vector refs = new Vector();\r
     for (int s = 0; s < seqs.length; s++)\r
     {\r
-      SequenceI dss = seqs[s];\r
-      while (dss.getDatasetSequence() != null)\r
+      if (seqs[s] != null)\r
       {\r
-        dss = dss.getDatasetSequence();\r
-      }\r
-      DBRefEntry[] rfs = findXDbRefs(dna, dss.getDBRef());\r
-      for (int r = 0; rfs != null && r < rfs.length; r++)\r
-      {\r
-        if (!refs.contains(rfs[r].getSource()))\r
+\r
+        SequenceI dss = seqs[s];\r
+        while (dss.getDatasetSequence() != null)\r
         {\r
-          refs.addElement(rfs[r].getSource());\r
+          dss = dss.getDatasetSequence();\r
         }\r
-      }\r
-      if (dataset != null)\r
-      {\r
-        // search for references to this sequence's direct references.\r
-        DBRefEntry[] lrfs = CrossRef.findXDbRefs(!dna, seqs[s].getDBRef());\r
-        Vector rseqs = new Vector();\r
-        CrossRef.searchDatasetXrefs(seqs[s], !dna, lrfs, dataset, rseqs,\r
-                null); // don't need to specify codon frame for mapping here\r
-        Enumeration lr = rseqs.elements();\r
-        while (lr.hasMoreElements())\r
+        DBRefEntry[] rfs = findXDbRefs(dna, dss.getDBRef());\r
+        for (int r = 0; rfs != null && r < rfs.length; r++)\r
         {\r
-          SequenceI rs = (SequenceI) lr.nextElement();\r
-          DBRefEntry[] xrs = findXDbRefs(dna, rs.getDBRef());\r
-          for (int r = 0; rfs != null && r < rfs.length; r++)\r
+          if (!refs.contains(rfs[r].getSource()))\r
           {\r
-            if (!refs.contains(rfs[r].getSource()))\r
+            refs.addElement(rfs[r].getSource());\r
+          }\r
+        }\r
+        if (dataset != null)\r
+        {\r
+          // search for references to this sequence's direct references.\r
+          DBRefEntry[] lrfs = CrossRef\r
+                  .findXDbRefs(!dna, seqs[s].getDBRef());\r
+          Vector rseqs = new Vector();\r
+          CrossRef.searchDatasetXrefs(seqs[s], !dna, lrfs, dataset, rseqs,\r
+                  null); // don't need to specify codon frame for mapping here\r
+          Enumeration lr = rseqs.elements();\r
+          while (lr.hasMoreElements())\r
+          {\r
+            SequenceI rs = (SequenceI) lr.nextElement();\r
+            DBRefEntry[] xrs = findXDbRefs(dna, rs.getDBRef());\r
+            for (int r = 0; rfs != null && r < rfs.length; r++)\r
             {\r
-              refs.addElement(rfs[r].getSource());\r
+              if (!refs.contains(rfs[r].getSource()))\r
+              {\r
+                refs.addElement(rfs[r].getSource());\r
+              }\r
             }\r
           }\r
         }\r
@@ -326,9 +331,9 @@ public class CrossRef
             try\r
             {\r
               retrieved = sftch.getSequences(xrfs); // problem here is we don't\r
-                                                    // know which of xrfs\r
-                                                    // resulted in which\r
-                                                    // retrieved element\r
+              // know which of xrfs\r
+              // resulted in which\r
+              // retrieved element\r
             } catch (Exception e)\r
             {\r
               System.err\r