From: gmungoc Date: Mon, 30 Nov 2015 10:05:57 +0000 (+0000) Subject: JAL-1421 generics loop syntax; 'bug?' comment added X-Git-Tag: Release_2_10_0~296^2~113 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5c6b5740b5bc6ac8e89dc04fe0a3542ee76cc22e;p=jalview.git JAL-1421 generics loop syntax; 'bug?' comment added --- diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 2e6431c..95d2396 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -25,6 +25,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; +import jalview.datamodel.Mapping; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; import jalview.util.DBRefUtils; @@ -88,41 +89,54 @@ public class CrossRef { String[] dbrefs = null; List refs = new ArrayList(); - for (int s = 0; s < seqs.length; s++) + for (SequenceI seq : seqs) { - if (seqs[s] != null) + if (seq != null) { - SequenceI dss = seqs[s]; + SequenceI dss = seq; while (dss.getDatasetSequence() != null) { dss = dss.getDatasetSequence(); } DBRefEntry[] rfs = findXDbRefs(dna, dss.getDBRef()); - for (int r = 0; rfs != null && r < rfs.length; r++) + if (rfs != null) { - if (!refs.contains(rfs[r].getSource())) + for (DBRefEntry ref : rfs) { - refs.add(rfs[r].getSource()); + if (!refs.contains(ref.getSource())) + { + refs.add(ref.getSource()); + } } } if (dataset != null) { // search for references to this sequence's direct references. - DBRefEntry[] lrfs = CrossRef - .findXDbRefs(!dna, seqs[s].getDBRef()); + DBRefEntry[] lrfs = CrossRef.findXDbRefs(!dna, seq.getDBRef()); List rseqs = new ArrayList(); - CrossRef.searchDatasetXrefs(seqs[s], !dna, lrfs, dataset, rseqs, + CrossRef.searchDatasetXrefs(seq, !dna, lrfs, dataset, rseqs, null); // don't need to specify codon frame for mapping here for (SequenceI rs : rseqs) { - DBRefEntry[] xrs = findXDbRefs(dna, rs.getDBRef()); // not used?? - for (int r = 0; rfs != null && r < rfs.length; r++) + DBRefEntry[] xrs = findXDbRefs(dna, rs.getDBRef()); + if (xrs != null) { - if (!refs.contains(rfs[r].getSource())) + for (DBRefEntry ref : xrs) { - refs.add(rfs[r].getSource()); + if (!refs.contains(ref.getSource())) + { + refs.add(ref.getSource()); + } } } + // looks like copy and paste - change rfs to xrs? + // for (int r = 0; rfs != null && r < rfs.length; r++) + // { + // if (!refs.contains(rfs[r].getSource())) + // { + // refs.add(rfs[r].getSource()); + // } + // } } } } @@ -135,13 +149,9 @@ public class CrossRef return dbrefs; } - /* - * if (dna) { if (rfs[r].hasMap()) { // most likely this is a protein cross - * reference if (!refs.contains(rfs[r].getSource())) { - * refs.addElement(rfs[r].getSource()); } } } - */ public static boolean hasCdnaMap(SequenceI[] seqs) { + // TODO unused - remove? String[] reftypes = findSequenceXrefTypes(false, seqs); for (int s = 0; s < reftypes.length; s++) { @@ -156,6 +166,7 @@ public class CrossRef public static SequenceI[] getCdnaMap(SequenceI[] seqs) { + // TODO unused - remove? Vector cseqs = new Vector(); for (int s = 0; s < seqs.length; s++) { @@ -199,7 +210,9 @@ public class CrossRef /** * * @param seqs + * sequences whose xrefs are being retrieved * @param dna + * true if sequences are nucleotide * @param source * @param dataset * alignment to search for product sequences. @@ -209,11 +222,10 @@ public class CrossRef String source, AlignmentI dataset) { List rseqs = new ArrayList(); - Alignment ral = null; - AlignedCodonFrame cf = new AlignedCodonFrame(); // nominal width - for (int s = 0; s < seqs.length; s++) + AlignedCodonFrame cf = new AlignedCodonFrame(); + for (SequenceI seq : seqs) { - SequenceI dss = seqs[s]; + SequenceI dss = seq; while (dss.getDatasetSequence() != null) { dss = dss.getDatasetSequence(); @@ -223,7 +235,8 @@ public class CrossRef if ((xrfs == null || xrfs.length == 0) && dataset != null) { System.out.println("Attempting to find ds Xrefs refs."); - DBRefEntry[] lrfs = CrossRef.findXDbRefs(!dna, seqs[s].getDBRef()); + // FIXME should be dss not seq here? + DBRefEntry[] lrfs = CrossRef.findXDbRefs(!dna, seq.getDBRef()); // less ambiguous would be a 'find primary dbRefEntry' method. // filter for desired source xref here found = CrossRef.searchDatasetXrefs(dss, !dna, lrfs, dataset, @@ -321,7 +334,7 @@ public class CrossRef { System.err .println("Problem whilst retrieving cross references for Sequence : " - + seqs[s].getName()); + + seq.getName()); e.printStackTrace(); } if (retrieved != null) @@ -329,15 +342,14 @@ public class CrossRef for (int rs = 0; rs < retrieved.length; rs++) { // TODO: examine each sequence for 'redundancy' - jalview.datamodel.DBRefEntry[] dbr = retrieved[rs] - .getDBRef(); + DBRefEntry[] dbr = retrieved[rs].getDBRef(); if (dbr != null && dbr.length > 0) { for (int di = 0; di < dbr.length; di++) { // find any entry where we should put in the sequence being // cross-referenced into the map - jalview.datamodel.Mapping map = dbr[di].getMap(); + Mapping map = dbr[di].getMap(); if (map != null) { if (map.getTo() != null && map.getMap() != null) @@ -382,6 +394,8 @@ public class CrossRef } } } + + Alignment ral = null; if (rseqs.size() > 0) { SequenceI[] rsqs = new SequenceI[rseqs.size()];