From: jprocter Date: Fri, 6 Feb 2009 14:56:21 +0000 (+0000) Subject: fix occasional nullpointer ref when seq ID retrieval doesn't resolve to a sequence... X-Git-Tag: Release_2_5~345 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=150bdda45255ff291d4ed3c75bcab837a50c2ac4;p=jalview.git fix occasional nullpointer ref when seq ID retrieval doesn't resolve to a sequence object --- diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 8bc844b..ffda7f2 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -104,36 +104,41 @@ public class CrossRef Vector refs = new Vector(); for (int s = 0; s < seqs.length; s++) { - SequenceI dss = seqs[s]; - while (dss.getDatasetSequence() != null) + if (seqs[s] != null) { - dss = dss.getDatasetSequence(); - } - DBRefEntry[] rfs = findXDbRefs(dna, dss.getDBRef()); - for (int r = 0; rfs != null && r < rfs.length; r++) - { - if (!refs.contains(rfs[r].getSource())) + + SequenceI dss = seqs[s]; + while (dss.getDatasetSequence() != null) { - refs.addElement(rfs[r].getSource()); + dss = dss.getDatasetSequence(); } - } - if (dataset != null) - { - // search for references to this sequence's direct references. - DBRefEntry[] lrfs = CrossRef.findXDbRefs(!dna, seqs[s].getDBRef()); - Vector rseqs = new Vector(); - CrossRef.searchDatasetXrefs(seqs[s], !dna, lrfs, dataset, rseqs, - null); // don't need to specify codon frame for mapping here - Enumeration lr = rseqs.elements(); - while (lr.hasMoreElements()) + DBRefEntry[] rfs = findXDbRefs(dna, dss.getDBRef()); + for (int r = 0; rfs != null && r < rfs.length; r++) { - SequenceI rs = (SequenceI) lr.nextElement(); - DBRefEntry[] xrs = findXDbRefs(dna, rs.getDBRef()); - for (int r = 0; rfs != null && r < rfs.length; r++) + if (!refs.contains(rfs[r].getSource())) { - if (!refs.contains(rfs[r].getSource())) + refs.addElement(rfs[r].getSource()); + } + } + if (dataset != null) + { + // search for references to this sequence's direct references. + DBRefEntry[] lrfs = CrossRef + .findXDbRefs(!dna, seqs[s].getDBRef()); + Vector rseqs = new Vector(); + CrossRef.searchDatasetXrefs(seqs[s], !dna, lrfs, dataset, rseqs, + null); // don't need to specify codon frame for mapping here + Enumeration lr = rseqs.elements(); + while (lr.hasMoreElements()) + { + SequenceI rs = (SequenceI) lr.nextElement(); + DBRefEntry[] xrs = findXDbRefs(dna, rs.getDBRef()); + for (int r = 0; rfs != null && r < rfs.length; r++) { - refs.addElement(rfs[r].getSource()); + if (!refs.contains(rfs[r].getSource())) + { + refs.addElement(rfs[r].getSource()); + } } } } @@ -326,9 +331,9 @@ public class CrossRef try { retrieved = sftch.getSequences(xrfs); // problem here is we don't - // know which of xrfs - // resulted in which - // retrieved element + // know which of xrfs + // resulted in which + // retrieved element } catch (Exception e) { System.err