X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FDBRefFetcher.java;h=b1c987ecd8400a39093002c31c0cfc846a76fa88;hb=3da878124135ff033f42d19d8733891b09e953cd;hp=35432040e27eadddcc818c06193aaa8dd854e124;hpb=81667097b92ba72f5eb4d824646b31e7ff5383a0;p=jalview.git diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 3543204..b1c987e 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -394,18 +394,19 @@ public class DBRefFetcher implements Runnable && (i < 50); seqIndex++, i++) { SequenceI sequence = dataset[seqIndex]; - DBRefEntry[] uprefs = DBRefUtils + List uprefs = DBRefUtils .selectRefs(sequence.getDBRefs(), new String[] { dbsource.getDbSource() }); // jalview.datamodel.DBRefSource.UNIPROT // }); // check for existing dbrefs to use - if (uprefs != null && uprefs.length > 0) + if (uprefs != null && uprefs.size() > 0) { - for (int j = 0; j < uprefs.length; j++) + for (int j = 0, n = uprefs.size(); j < n; j++) { - addSeqId(sequence, uprefs[j].getAccessionId()); + DBRefEntry upref = uprefs.get(j); + addSeqId(sequence, upref.getAccessionId()); queries.addElement( - uprefs[j].getAccessionId().toUpperCase()); + upref.getAccessionId().toUpperCase()); } } else @@ -532,7 +533,7 @@ public class DBRefFetcher implements Runnable // taking into account all accessionIds and names in the file Vector sequenceMatches = new Vector<>(); // look for corresponding accession ids - DBRefEntry[] entryRefs = DBRefUtils + List entryRefs = DBRefUtils .selectRefs(retrievedSeq.getDBRefs(), new String[] { dbSource }); if (entryRefs == null) @@ -542,9 +543,10 @@ public class DBRefFetcher implements Runnable + dbSource + " on " + retrievedSeq.getName()); continue; } - for (int j = 0; j < entryRefs.length; j++) + for (int j = 0, n = entryRefs.size(); j < n; j++) { - String accessionId = entryRefs[j].getAccessionId(); + DBRefEntry ref = entryRefs.get(j); + String accessionId = ref.getAccessionId(); // match up on accessionId if (seqRefs.containsKey(accessionId.toUpperCase())) { @@ -582,7 +584,7 @@ public class DBRefFetcher implements Runnable // could be useful to extend this so we try to find any 'significant' // information in common between two sequence objects. /* - * DBRefEntry[] entryRefs = + * List entryRefs = * jalview.util.DBRefUtils.selectRefs(entry.getDBRef(), new String[] { * dbSource }); for (int j = 0; j < entry.getName().size(); j++) { String * name = entry.getName().elementAt(j).toString(); if @@ -603,7 +605,7 @@ public class DBRefFetcher implements Runnable // TODO: test for legacy where uniprot or EMBL refs exist but no // mappings are made (but content matches retrieved set) boolean updateRefFrame = sequence.getDBRefs() == null - || sequence.getDBRefs().length == 0; + || sequence.getDBRefs().size() == 0; // TODO: // verify sequence against the entry sequence @@ -669,7 +671,8 @@ public class DBRefFetcher implements Runnable int startShift = absStart - sequenceStart + 1; if (startShift != 0) { - modified |= sequence.getFeatures().shiftFeatures(startShift); + modified |= sequence.getFeatures().shiftFeatures(1, + startShift); } } } @@ -753,8 +756,6 @@ public class DBRefFetcher implements Runnable // and remove it from the rest // TODO: decide if we should remove annotated sequence from set sdataset.remove(sequence); - // TODO: should we make a note of sequences that have received new DB - // ids, so we can query all enabled DAS servers for them ? } } return modified; @@ -782,28 +783,33 @@ public class DBRefFetcher implements Runnable */ private SequenceI[] recoverDbSequences(SequenceI[] sequencesArray) { - Vector nseq = new Vector<>(); - for (int i = 0; sequencesArray != null - && i < sequencesArray.length; i++) + int n; + if (sequencesArray == null || (n = sequencesArray.length) == 0) + return sequencesArray; + ArrayList nseq = new ArrayList<>(); + for (int i = 0;i < n; i++) { - nseq.addElement(sequencesArray[i]); - DBRefEntry[] dbr = sequencesArray[i].getDBRefs(); + nseq.add(sequencesArray[i]); + List dbr = sequencesArray[i].getDBRefs(); Mapping map = null; - for (int r = 0; (dbr != null) && r < dbr.length; r++) + if (dbr != null) { - if ((map = dbr[r].getMap()) != null) + for (int r = 0, rn = dbr.size(); r < rn; r++) { - if (map.getTo() != null && !nseq.contains(map.getTo())) + if ((map = dbr.get(r).getMap()) != null) { - nseq.addElement(map.getTo()); - } + if (map.getTo() != null && !nseq.contains(map.getTo())) + { + nseq.add(map.getTo()); + } + } } } } + // BH 2019.01.25 question here if this is the right logic. Return the original if nothing found? if (nseq.size() > 0) { - sequencesArray = new SequenceI[nseq.size()]; - nseq.toArray(sequencesArray); + return nseq.toArray(new SequenceI[nseq.size()]); } return sequencesArray; }