X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2FDBRefFetcher.java;h=fb8864d6f1f42bfdbe52a72015ee30c69a5b91a7;hb=be762d8d9c71a7aa3121e845c45911c7192b7827;hp=8c8a717dc2928ed67fee511f5d9f8ea188c15f60;hpb=d1bb7a31fc091606aedbc255a5766ac79e36fa91;p=jalview.git diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 8c8a717..fb8864d 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -164,9 +164,9 @@ public class DBRefFetcher implements Runnable // af.featureSettings_actionPerformed(null); String[] defdb = null; List selsources = new ArrayList(); - Vector dasselsrc = (featureSettings != null) ? featureSettings - .getSelectedSources() : new DasSourceBrowser() - .getSelectedSources(); + Vector dasselsrc = (featureSettings != null) + ? featureSettings.getSelectedSources() + : new DasSourceBrowser().getSelectedSources(); for (jalviewSourceI src : dasselsrc) { @@ -250,7 +250,8 @@ public class DBRefFetcher implements Runnable DbSourceProxy[] newsrc = new DbSourceProxy[dbSources.length + otherdb.length]; System.arraycopy(dbSources, 0, newsrc, 0, dbSources.length); - System.arraycopy(otherdb, 0, newsrc, dbSources.length, otherdb.length); + System.arraycopy(otherdb, 0, newsrc, dbSources.length, + otherdb.length); dbSources = newsrc; } } @@ -330,9 +331,8 @@ public class DBRefFetcher implements Runnable { if (dbSources == null) { - throw new Error( - MessageManager - .getString("error.implementation_error_must_init_dbsources")); + throw new Error(MessageManager + .getString("error.implementation_error_must_init_dbsources")); } running = true; long startTime = System.currentTimeMillis(); @@ -397,8 +397,8 @@ public class DBRefFetcher implements Runnable String query = queries.elementAt(0); if (dbsource.isValidReference(query)) { - queryString.append((numq == 0) ? "" : dbsource - .getAccessionSeparator()); + queryString.append( + (numq == 0) ? "" : dbsource.getAccessionSeparator()); queryString.append(query); numq++; } @@ -432,12 +432,13 @@ public class DBRefFetcher implements Runnable else { // make some more strings for use as queries - for (int i = 0; (seqIndex < dataset.length) && (i < 50); seqIndex++, i++) + for (int i = 0; (seqIndex < dataset.length) + && (i < 50); seqIndex++, i++) { SequenceI sequence = dataset[seqIndex]; - DBRefEntry[] uprefs = DBRefUtils.selectRefs( - sequence.getDBRefs(), - new String[] { dbsource.getDbSource() }); // jalview.datamodel.DBRefSource.UNIPROT + DBRefEntry[] 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) @@ -445,7 +446,8 @@ public class DBRefFetcher implements Runnable for (int j = 0; j < uprefs.length; j++) { addSeqId(sequence, uprefs[j].getAccessionId()); - queries.addElement(uprefs[j].getAccessionId().toUpperCase()); + queries.addElement( + uprefs[j].getAccessionId().toUpperCase()); } } else @@ -462,14 +464,13 @@ public class DBRefFetcher implements Runnable // resolve the string against PICR to recover valid IDs try { - presp = picrClient - .getUPIForAccession(token, null, - picrClient.getMappedDatabaseNames(), - null, true); + presp = picrClient.getUPIForAccession(token, null, + picrClient.getMappedDatabaseNames(), null, + true); } catch (Exception e) { - System.err.println("Exception with Picr for '" + token - + "'\n"); + System.err.println( + "Exception with Picr for '" + token + "'\n"); e.printStackTrace(); } } @@ -481,8 +482,8 @@ public class DBRefFetcher implements Runnable // present, and do a transferReferences // otherwise transfer non sequence x-references directly. } - System.out - .println("Validated ID against PICR... (for what its worth):" + System.out.println( + "Validated ID against PICR... (for what its worth):" + token); addSeqId(sequence, token); queries.addElement(token.toUpperCase()); @@ -490,7 +491,8 @@ public class DBRefFetcher implements Runnable else { // if () - // System.out.println("Not querying source with token="+token+"\n"); + // System.out.println("Not querying source with + // token="+token+"\n"); addSeqId(sequence, token); queries.addElement(token.toUpperCase()); } @@ -514,7 +516,8 @@ public class DBRefFetcher implements Runnable output.setText(sb.toString()); Desktop.addInternalFrame(output, - MessageManager.getString("label.sequences_updated"), 600, 300); + MessageManager.getString("label.sequences_updated"), 600, + 300); // The above is the dataset, we must now find out the index // of the viewed sequence @@ -561,8 +564,8 @@ public class DBRefFetcher implements Runnable } boolean modified = false; - SequenceI[] retrieved = recoverDbSequences(retrievedAl - .getSequencesArray()); + SequenceI[] retrieved = recoverDbSequences( + retrievedAl.getSequencesArray()); SequenceI sequence = null; for (SequenceI retrievedSeq : retrieved) @@ -571,8 +574,9 @@ 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.selectRefs( - retrievedSeq.getDBRefs(), new String[] { dbSource }); + DBRefEntry[] entryRefs = DBRefUtils + .selectRefs(retrievedSeq.getDBRefs(), new String[] + { dbSource }); if (entryRefs == null) { System.err @@ -649,8 +653,9 @@ public class DBRefFetcher implements Runnable final int sequenceStart = sequence.getStart(); boolean remoteEnclosesLocal = false; - String nonGapped = AlignSeq.extractGaps("-. ", - sequence.getSequenceAsString()).toUpperCase(); + String nonGapped = AlignSeq + .extractGaps("-. ", sequence.getSequenceAsString()) + .toUpperCase(); int absStart = entrySeq.indexOf(nonGapped); if (absStart == -1) { @@ -680,10 +685,14 @@ public class DBRefFetcher implements Runnable * So create a mapping to the external entry from the matching region of * the local sequence, and leave local start/end untouched. */ - mp = new Mapping(null, new int[] { sequenceStart + absStart, - sequenceStart + absStart + entrySeq.length() - 1 }, new int[] - { retrievedSeq.getStart(), - retrievedSeq.getStart() + entrySeq.length() - 1 }, 1, 1); + mp = new Mapping(null, + new int[] + { sequenceStart + absStart, + sequenceStart + absStart + entrySeq.length() - 1 }, + new int[] + { retrievedSeq.getStart(), + retrievedSeq.getStart() + entrySeq.length() - 1 }, + 1, 1); updateRefFrame = false; } else @@ -725,8 +734,8 @@ public class DBRefFetcher implements Runnable sequence.setSequence(retrievedSeqString); modified = true; addWarningMessage(warningMessages, - "Sequence for " + sequence.getName() - + " expanded from " + retrievedSeq.getName()); + "Sequence for " + sequence.getName() + " expanded from " + + retrievedSeq.getName()); } if (sequence.getStart() != retrievedSeq.getStart()) { @@ -734,9 +743,9 @@ public class DBRefFetcher implements Runnable modified = true; if (absStart != sequenceStart) { - addWarningMessage(warningMessages, "Start/end position for " - + sequence.getName() + " updated from " - + retrievedSeq.getName()); + addWarningMessage(warningMessages, + "Start/end position for " + sequence.getName() + + " updated from " + retrievedSeq.getName()); } } } @@ -752,9 +761,9 @@ public class DBRefFetcher implements Runnable sequence.setStart(absStart); sequence.setEnd(absEnd); modified = true; - addWarningMessage(warningMessages, "Start/end for " - + sequence.getName() + " updated from " - + retrievedSeq.getName()); + addWarningMessage(warningMessages, + "Start/end for " + sequence.getName() + + " updated from " + retrievedSeq.getName()); } } // search for alignment sequences to update coordinate frame for @@ -762,16 +771,17 @@ public class DBRefFetcher implements Runnable { if (alseqs[alsq].getDatasetSequence() == sequence) { - String ngAlsq = AlignSeq.extractGaps("-. ", - alseqs[alsq].getSequenceAsString()).toUpperCase(); + String ngAlsq = AlignSeq + .extractGaps("-. ", + alseqs[alsq].getSequenceAsString()) + .toUpperCase(); int oldstrt = alseqs[alsq].getStart(); alseqs[alsq].setStart(sequence.getSequenceAsString() - .toUpperCase().indexOf(ngAlsq) - + sequence.getStart()); + .toUpperCase().indexOf(ngAlsq) + sequence.getStart()); if (oldstrt != alseqs[alsq].getStart()) { - alseqs[alsq].setEnd(ngAlsq.length() - + alseqs[alsq].getStart() - 1); + alseqs[alsq].setEnd( + ngAlsq.length() + alseqs[alsq].getStart() - 1); modified = true; } } @@ -815,7 +825,8 @@ public class DBRefFetcher implements Runnable private SequenceI[] recoverDbSequences(SequenceI[] sequencesArray) { Vector nseq = new Vector(); - for (int i = 0; sequencesArray != null && i < sequencesArray.length; i++) + for (int i = 0; sequencesArray != null + && i < sequencesArray.length; i++) { nseq.addElement(sequencesArray[i]); DBRefEntry[] dbr = sequencesArray[i].getDBRefs();