From a21b84a669a9620f6943b9b5054e8756cb6f0687 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Thu, 15 Oct 2015 15:16:37 +0100 Subject: [PATCH] JAL-1479 refactored SequenceI interface - changed getDBRef() to getDBRefs() since it returns an array of DBRefEntry --- src/jalview/analysis/AlignmentUtils.java | 4 +- src/jalview/analysis/CrossRef.java | 16 ++--- src/jalview/analysis/Dna.java | 6 +- src/jalview/analysis/SequenceIdMatcher.java | 4 +- src/jalview/api/DBRefEntryI.java | 8 +++ src/jalview/appletgui/APopupMenu.java | 2 +- src/jalview/datamodel/DBRefEntry.java | 21 +++++++ src/jalview/datamodel/Sequence.java | 12 ++-- src/jalview/datamodel/SequenceGroup.java | 2 +- src/jalview/datamodel/SequenceI.java | 2 +- src/jalview/gui/Jalview2XML.java | 6 +- src/jalview/gui/PopupMenu.java | 4 +- src/jalview/gui/SequenceFetcher.java | 2 +- src/jalview/gui/StructureChooser.java | 4 +- src/jalview/gui/TreePanel.java | 2 +- src/jalview/io/ModellerDescription.java | 4 +- src/jalview/io/SequenceAnnotationReport.java | 4 +- src/jalview/io/StockholmFile.java | 8 +-- src/jalview/io/WSWUBlastClient.java | 2 +- src/jalview/io/vamsas/Datasetsequence.java | 4 +- src/jalview/io/vamsas/Sequencemapping.java | 10 ++-- .../structure/StructureSelectionManager.java | 61 +++++++++++++++++++- src/jalview/ws/DBRefFetcher.java | 10 ++-- src/jalview/ws/DasSequenceFeatureFetcher.java | 4 +- src/jalview/ws/seqfetcher/ASequenceFetcher.java | 2 +- test/jalview/analysis/AlignmentUtilsTests.java | 16 ++--- test/jalview/util/DBRefUtilsTest.java | 4 +- test/jalview/ws/seqfetcher/DbRefFetcherTest.java | 2 +- 28 files changed, 156 insertions(+), 70 deletions(-) diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index 898e4f7..da5bc2f 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -1284,7 +1284,7 @@ public class AlignmentUtils return false; } String name = seq2.getName(); - final DBRefEntry[] xrefs = seq1.getDBRef(); + final DBRefEntry[] xrefs = seq1.getDBRefs(); if (xrefs != null) { for (DBRefEntry xref : xrefs) @@ -1402,7 +1402,7 @@ public class AlignmentUtils String cdsAccId = FeatureProperties .getCodingFeature(DBRefSource.EMBL); DBRefEntry[] cdsRefs = DBRefUtils.selectRefs(seqMapping.getTo() - .getDBRef(), DBRefSource.CODINGDBS); + .getDBRefs(), DBRefSource.CODINGDBS); if (cdsRefs != null) { for (DBRefEntry cdsRef : cdsRefs) diff --git a/src/jalview/analysis/CrossRef.java b/src/jalview/analysis/CrossRef.java index 2e6431c..a71e614 100644 --- a/src/jalview/analysis/CrossRef.java +++ b/src/jalview/analysis/CrossRef.java @@ -97,7 +97,7 @@ public class CrossRef { dss = dss.getDatasetSequence(); } - DBRefEntry[] rfs = findXDbRefs(dna, dss.getDBRef()); + DBRefEntry[] rfs = findXDbRefs(dna, dss.getDBRefs()); for (int r = 0; rfs != null && r < rfs.length; r++) { if (!refs.contains(rfs[r].getSource())) @@ -109,13 +109,13 @@ public class CrossRef { // search for references to this sequence's direct references. DBRefEntry[] lrfs = CrossRef - .findXDbRefs(!dna, seqs[s].getDBRef()); + .findXDbRefs(!dna, seqs[s].getDBRefs()); List rseqs = new ArrayList(); CrossRef.searchDatasetXrefs(seqs[s], !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?? + DBRefEntry[] xrs = findXDbRefs(dna, rs.getDBRefs()); // not used?? for (int r = 0; rfs != null && r < rfs.length; r++) { if (!refs.contains(rfs[r].getSource())) @@ -159,7 +159,7 @@ public class CrossRef Vector cseqs = new Vector(); for (int s = 0; s < seqs.length; s++) { - DBRefEntry[] cdna = findXDbRefs(true, seqs[s].getDBRef()); + DBRefEntry[] cdna = findXDbRefs(true, seqs[s].getDBRefs()); for (int c = 0; c < cdna.length; c++) { if (cdna[c].getSource().equals(DBRefSource.EMBLCDS)) @@ -219,11 +219,11 @@ public class CrossRef dss = dss.getDatasetSequence(); } boolean found = false; - DBRefEntry[] xrfs = CrossRef.findXDbRefs(dna, dss.getDBRef()); + DBRefEntry[] xrfs = CrossRef.findXDbRefs(dna, dss.getDBRefs()); 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()); + DBRefEntry[] lrfs = CrossRef.findXDbRefs(!dna, seqs[s].getDBRefs()); // less ambiguous would be a 'find primary dbRefEntry' method. // filter for desired source xref here found = CrossRef.searchDatasetXrefs(dss, !dna, lrfs, dataset, @@ -330,7 +330,7 @@ public class CrossRef { // TODO: examine each sequence for 'redundancy' jalview.datamodel.DBRefEntry[] dbr = retrieved[rs] - .getDBRef(); + .getDBRefs(); if (dbr != null && dbr.length > 0) { for (int di = 0; di < dbr.length; di++) @@ -500,7 +500,7 @@ public class CrossRef } // look for direct or indirect references in common - DBRefEntry[] poss = nxt.getDBRef(), cands = null; + DBRefEntry[] poss = nxt.getDBRefs(), cands = null; if (direct) { cands = jalview.util.DBRefUtils.searchRefs(poss, xrf); diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index 9ce00cc..2939e3c 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -208,13 +208,13 @@ public class Dna for (int gd = 0; gd < selection.length; gd++) { SequenceI dna = selection[gd]; - DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRef(), + DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(), jalview.datamodel.DBRefSource.DNACODINGDBS); if (dnarefs != null) { // intersect with pep List mappedrefs = new ArrayList(); - DBRefEntry[] refs = dna.getDBRef(); + DBRefEntry[] refs = dna.getDBRefs(); for (int d = 0; d < refs.length; d++) { if (refs[d].getMap() != null && refs[d].getMap().getMap() != null @@ -773,7 +773,7 @@ public class Dna { SequenceFeature[] sfs = dna.getSequenceFeatures(); Boolean fgstate; - DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRef(), + DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(), DBRefSource.DNACODINGDBS); if (dnarefs != null) { diff --git a/src/jalview/analysis/SequenceIdMatcher.java b/src/jalview/analysis/SequenceIdMatcher.java index 35a72e3..454bc09 100755 --- a/src/jalview/analysis/SequenceIdMatcher.java +++ b/src/jalview/analysis/SequenceIdMatcher.java @@ -63,9 +63,9 @@ public class SequenceIdMatcher dbseq = dbseq.getDatasetSequence(); } // add in any interesting identifiers - if (dbseq.getDBRef() != null) + if (dbseq.getDBRefs() != null) { - DBRefEntry dbr[] = dbseq.getDBRef(); + DBRefEntry dbr[] = dbseq.getDBRefs(); SeqIdName sid = null; for (int r = 0; r < dbr.length; r++) { diff --git a/src/jalview/api/DBRefEntryI.java b/src/jalview/api/DBRefEntryI.java index 731c258..3238781 100644 --- a/src/jalview/api/DBRefEntryI.java +++ b/src/jalview/api/DBRefEntryI.java @@ -16,4 +16,12 @@ public interface DBRefEntryI public void setSource(String source); public void setVersion(String version); + + public void setStartRes(int startRes); + + public int getStartRes(); + + public void setEndRes(int endRes); + + public int getEndRes(); } diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index 1d2feb2..748954a 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -274,7 +274,7 @@ public class APopupMenu extends java.awt.PopupMenu implements // collect matching db-refs DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs( - seq.getDBRef(), new String[] { target }); + seq.getDBRefs(), new String[] { target }); // collect id string too String id = seq.getName(); String descr = seq.getDescription(); diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 0d6f68d..142d996 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -26,6 +26,7 @@ public class DBRefEntry implements DBRefEntryI { String source = "", version = "", accessionId = ""; + private int startRes, endRes; /** * maps from associated sequence to the database sequence's coordinate system */ @@ -209,4 +210,24 @@ public class DBRefEntry implements DBRefEntryI { return getSrcAccString(); } + + public int getStartRes() + { + return startRes; + } + + public void setStartRes(int startRes) + { + this.startRes = startRes; + } + + public int getEndRes() + { + return endRes; + } + + public void setEndRes(int endRes) + { + this.endRes = endRes; + } } diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index 9f65f71..c8bd902 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -228,10 +228,10 @@ public class Sequence extends ASequence implements SequenceI } } setDatasetSequence(seq.getDatasetSequence()); - if (datasetSequence == null && seq.getDBRef() != null) + if (datasetSequence == null && seq.getDBRefs() != null) { // only copy DBRefs if we really are a dataset sequence - DBRefEntry[] dbr = seq.getDBRef(); + DBRefEntry[] dbr = seq.getDBRefs(); for (int i = 0; i < dbr.length; i++) { addDBRef(new DBRefEntry(dbr[i])); @@ -917,12 +917,12 @@ public class Sequence extends ASequence implements SequenceI } @Override - public DBRefEntry[] getDBRef() + public DBRefEntry[] getDBRefs() { if (dbrefs == null && datasetSequence != null && this != datasetSequence) { - return datasetSequence.getDBRef(); + return datasetSequence.getDBRefs(); } return dbrefs; } @@ -1079,7 +1079,7 @@ public class Sequence extends ASequence implements SequenceI datasetSequence.setDescription(getDescription()); setSequenceFeatures(null); // move database references onto dataset sequence - datasetSequence.setDBRef(getDBRef()); + datasetSequence.setDBRef(getDBRefs()); setDBRef(null); datasetSequence.setPDBId(getAllPDBEntries()); setPDBId(null); @@ -1255,7 +1255,7 @@ public class Sequence extends ASequence implements SequenceI } } // transfer database references - DBRefEntry[] entryRefs = entry.getDBRef(); + DBRefEntry[] entryRefs = entry.getDBRefs(); if (entryRefs != null) { for (int r = 0; r < entryRefs.length; r++) diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index cc70e25..d79a5f7 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -209,7 +209,7 @@ public class SequenceGroup implements AnnotatedCollectionI if (seqs[ipos] != null) { seqs[ipos].setDescription(seq.getDescription()); - seqs[ipos].setDBRef(seq.getDBRef()); + seqs[ipos].setDBRef(seq.getDBRefs()); seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures()); if (seq.getDatasetSequence() != null) { diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index 49b0e4d..50f88f3 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -300,7 +300,7 @@ public interface SequenceI extends ASequenceI public void setDBRef(DBRefEntry[] dbs); - public DBRefEntry[] getDBRef(); + public DBRefEntry[] getDBRefs(); /** * add the given entry to the list of DBRefs for this sequence, or replace a diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 50a8167..fc96edc 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -1948,16 +1948,16 @@ public class Jalview2XML if (jds.getDatasetSequence() != null) { vamsasSeq.setDsseqid(seqHash(jds.getDatasetSequence())); - if (jds.getDatasetSequence().getDBRef() != null) + if (jds.getDatasetSequence().getDBRefs() != null) { - dbrefs = jds.getDatasetSequence().getDBRef(); + dbrefs = jds.getDatasetSequence().getDBRefs(); } } else { vamsasSeq.setDsseqid(id); // so we can tell which sequences really are // dataset sequences only - dbrefs = jds.getDBRef(); + dbrefs = jds.getDBRefs(); } if (dbrefs != null) { diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index fee47e5..3491431 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -642,7 +642,7 @@ public class PopupMenu extends JPopupMenu // collect matching db-refs DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs( - seq.getDBRef(), new String[] { urlLink.getTarget() }); + seq.getDBRefs(), new String[] { urlLink.getTarget() }); // collect id string too String id = seq.getName(); String descr = seq.getDescription(); @@ -896,7 +896,7 @@ public class PopupMenu extends JPopupMenu { sqi = sqi.getDatasetSequence(); } - DBRefEntry[] dbr = sqi.getDBRef(); + DBRefEntry[] dbr = sqi.getDBRefs(); if (dbr != null && dbr.length > 0) { for (int d = 0; d < dbr.length; d++) diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index a973757..191e8fe 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -661,7 +661,7 @@ public class SequenceFetcher extends JPanel implements Runnable { if (rs[r] != null && (found = DBRefUtils.searchRefs( - rs[r].getDBRef(), dbr)) != null + rs[r].getDBRefs(), dbr)) != null && found.length > 0) { rfound = true; diff --git a/src/jalview/gui/StructureChooser.java b/src/jalview/gui/StructureChooser.java index 63a8654..2a7da57 100644 --- a/src/jalview/gui/StructureChooser.java +++ b/src/jalview/gui/StructureChooser.java @@ -257,10 +257,10 @@ public class StructureChooser extends GStructureChooser } } - if (seq.getDBRef() != null && seq.getDBRef().length != 0) + if (seq.getDBRefs() != null && seq.getDBRefs().length != 0) { int count = 0; - for (DBRefEntry dbRef : seq.getDBRef()) + for (DBRefEntry dbRef : seq.getDBRefs()) { if (isValidSeqName(getDBRefId(dbRef))) { diff --git a/src/jalview/gui/TreePanel.java b/src/jalview/gui/TreePanel.java index d2c86c8..9522144 100755 --- a/src/jalview/gui/TreePanel.java +++ b/src/jalview/gui/TreePanel.java @@ -840,7 +840,7 @@ public class TreePanel extends GTreePanel { // search dbrefs, features and annotation DBRefEntry[] refs = jalview.util.DBRefUtils.selectRefs( - sq.getDBRef(), + sq.getDBRefs(), new String[] { labelClass.toUpperCase() }); if (refs != null) { diff --git a/src/jalview/io/ModellerDescription.java b/src/jalview/io/ModellerDescription.java index 55324ad..1ab9545 100755 --- a/src/jalview/io/ModellerDescription.java +++ b/src/jalview/io/ModellerDescription.java @@ -268,10 +268,10 @@ public class ModellerDescription // sets the local reference field int t = 0; // sequence if (seq.getDatasetSequence() != null - && seq.getDatasetSequence().getDBRef() != null) + && seq.getDatasetSequence().getDBRefs() != null) { jalview.datamodel.DBRefEntry[] dbr = seq.getDatasetSequence() - .getDBRef(); + .getDBRefs(); int i, j; for (i = 0, j = dbr.length; i < j; i++) { diff --git a/src/jalview/io/SequenceAnnotationReport.java b/src/jalview/io/SequenceAnnotationReport.java index 72f8044..d3a1d09 100644 --- a/src/jalview/io/SequenceAnnotationReport.java +++ b/src/jalview/io/SequenceAnnotationReport.java @@ -230,7 +230,7 @@ public class SequenceAnnotationReport { // collect matching db-refs - DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), + DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(seq.getDBRefs(), new String[] { target }); // collect id string too String id = seq.getName(); @@ -346,7 +346,7 @@ public class SequenceAnnotationReport { ds = ds.getDatasetSequence(); } - DBRefEntry[] dbrefs = ds.getDBRef(); + DBRefEntry[] dbrefs = ds.getDBRefs(); if (showDbRefs && dbrefs != null) { for (int i = 0; i < dbrefs.length; i++) diff --git a/src/jalview/io/StockholmFile.java b/src/jalview/io/StockholmFile.java index 9135b92..23c4d21 100644 --- a/src/jalview/io/StockholmFile.java +++ b/src/jalview/io/StockholmFile.java @@ -900,18 +900,18 @@ public class StockholmFile extends AlignFile { maxid = tmp.length(); } - if (s[in].getDBRef() != null) + if (s[in].getDBRefs() != null) { - for (int idb = 0; idb < s[in].getDBRef().length; idb++) + for (int idb = 0; idb < s[in].getDBRefs().length; idb++) { if (dataRef == null) { dataRef = new Hashtable(); } - String datAs1 = s[in].getDBRef()[idb].getSource().toString() + String datAs1 = s[in].getDBRefs()[idb].getSource().toString() + " ; " - + s[in].getDBRef()[idb].getAccessionId().toString(); + + s[in].getDBRefs()[idb].getAccessionId().toString(); dataRef.put(tmp, datAs1); } } diff --git a/src/jalview/io/WSWUBlastClient.java b/src/jalview/io/WSWUBlastClient.java index a6c1111..9d9b940 100755 --- a/src/jalview/io/WSWUBlastClient.java +++ b/src/jalview/io/WSWUBlastClient.java @@ -176,7 +176,7 @@ public class WSWUBlastClient } } - DBRefEntry[] entries = oldseq.getDBRef(); + DBRefEntry[] entries = oldseq.getDBRefs(); if (entries != null) { oldseq.addDBRef(new jalview.datamodel.DBRefEntry( diff --git a/src/jalview/io/vamsas/Datasetsequence.java b/src/jalview/io/vamsas/Datasetsequence.java index f1b9f1a..9db7a8e 100644 --- a/src/jalview/io/vamsas/Datasetsequence.java +++ b/src/jalview/io/vamsas/Datasetsequence.java @@ -175,10 +175,10 @@ public class Datasetsequence extends DatastoreItem boolean modifiedthedoc = false; SequenceI sq = (SequenceI) jvobj; - if (sq.getDatasetSequence() == null && sq.getDBRef() != null) + if (sq.getDatasetSequence() == null && sq.getDBRefs() != null) { // only sync database references for dataset sequences - DBRefEntry[] entries = sq.getDBRef(); + DBRefEntry[] entries = sq.getDBRefs(); // jalview.datamodel.DBRefEntry dbentry; for (int db = 0; db < entries.length; db++) { diff --git a/src/jalview/io/vamsas/Sequencemapping.java b/src/jalview/io/vamsas/Sequencemapping.java index 31ccc48..160f5e2 100644 --- a/src/jalview/io/vamsas/Sequencemapping.java +++ b/src/jalview/io/vamsas/Sequencemapping.java @@ -386,7 +386,7 @@ public class Sequencemapping extends Rangetype private void matchConjugateDBRefs(SequenceI from, SequenceI to, jalview.util.MapList smap) { - if (from.getDBRef() == null && to.getDBRef() == null) + if (from.getDBRefs() == null && to.getDBRefs() == null) { if (jalview.bin.Cache.log.isDebugEnabled()) { @@ -400,11 +400,11 @@ public class Sequencemapping extends Rangetype jalview.bin.Cache.log.debug("Matching conjugate refs for " + from.getName() + " and " + to.getName()); } - jalview.datamodel.DBRefEntry[] fdb = from.getDBRef(); + jalview.datamodel.DBRefEntry[] fdb = from.getDBRefs(); jalview.datamodel.DBRefEntry[] tdb = new jalview.datamodel.DBRefEntry[to - .getDBRef().length]; - int tdblen = to.getDBRef().length; - System.arraycopy(to.getDBRef(), 0, tdb, 0, tdblen); + .getDBRefs().length]; + int tdblen = to.getDBRefs().length; + System.arraycopy(to.getDBRefs(), 0, tdb, 0, tdblen); Vector matched = new Vector(); jalview.util.MapList smapI = smap.getInverse(); for (int f = 0; f < fdb.length; f++) diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 59d8631..e9d736f 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -33,6 +33,7 @@ import jalview.datamodel.PDBEntry; import jalview.datamodel.SearchResults; import jalview.datamodel.SequenceI; import jalview.io.AppletFormatAdapter; +import jalview.io.SiftsClient; import jalview.util.MappingUtils; import jalview.util.MessageManager; @@ -479,6 +480,8 @@ public class StructureSelectionManager } }; + // mapWithNWAlignment(); + // mapWithSIFTS(); maxAlignseq.printAlignment(ps); mappingDetails.append(NEWLINE).append("PDB start/end "); @@ -528,8 +531,10 @@ public class StructureSelectionManager { pdbFile = "INLINE" + pdb.id; } - StructureMapping newMapping = new StructureMapping(seq, pdbFile, - pdb.id, maxChainId, mapping, mappingDetails.toString()); + // StructureMapping newMapping = new StructureMapping(seq, pdbFile, + // pdb.id, maxChainId, mapping, mappingDetails.toString()); + StructureMapping newMapping = new SiftsClient(pdb.id) + .getSiftsMappingsFor(seq, pdbFile, maxChainId); if (forStructureView) { mappings.add(newMapping); @@ -541,6 +546,58 @@ public class StructureSelectionManager return pdb; } + private StructureMapping mapWithNWAlignment(StringBuilder mappingDetails, + PDBChain maxChain, AlignSeq maxAlignseq, SequenceI seq, + PrintStream ps) + { + maxAlignseq.printAlignment(ps); + + mappingDetails.append(NEWLINE).append("PDB start/end "); + mappingDetails.append(String.valueOf(maxAlignseq.seq2start)) + .append(" "); + mappingDetails.append(String.valueOf(maxAlignseq.seq2end)); + mappingDetails.append(NEWLINE).append("SEQ start/end "); + // TODO JAL-1887 should be fixed from here + mappingDetails.append( + String.valueOf(maxAlignseq.seq1start + seq.getStart() - 1)) + .append(" "); + mappingDetails.append(String.valueOf(maxAlignseq.seq1end + seq.getEnd() + - 1)); + + maxChain.makeExactMapping(maxAlignseq, seq); + jalview.datamodel.Mapping sqmpping = maxAlignseq + .getMappingFromS1(false); + jalview.datamodel.Mapping omap = new jalview.datamodel.Mapping(sqmpping + .getMap().getInverse()); + maxChain.transferRESNUMFeatures(seq, null); + + // allocate enough slots to store the mapping from positions in + // sequence[s] to the associated chain + int[][] mapping = new int[seq.findPosition(seq.getLength()) + 2][2]; + int resNum = -10000; + int index = 0; + + do + { + Atom tmp = maxChain.atoms.elementAt(index); + if (resNum != tmp.resNumber && tmp.alignmentMapping != -1) + { + resNum = tmp.resNumber; + if (tmp.alignmentMapping >= -1) + { + // TODO (JAL-1836) address root cause: negative residue no in PDB + // file + mapping[tmp.alignmentMapping + 1][0] = tmp.resNumber; + mapping[tmp.alignmentMapping + 1][1] = tmp.atomIndex; + } + } + + index++; + } while (index < maxChain.atoms.size()); + + return null; + } + public void removeStructureViewerListener(Object svl, String[] pdbfiles) { listeners.removeElement(svl); diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index d531fea..b708ec1 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -400,7 +400,7 @@ public class DBRefFetcher implements Runnable { SequenceI sequence = dataset[seqIndex]; DBRefEntry[] uprefs = jalview.util.DBRefUtils.selectRefs( - sequence.getDBRef(), + sequence.getDBRefs(), new String[] { dbsource.getDbSource() }); // jalview.datamodel.DBRefSource.UNIPROT // }); // check for existing dbrefs to use @@ -524,7 +524,7 @@ public class DBRefFetcher implements Runnable Vector sequenceMatches = new Vector(); // look for corresponding accession ids DBRefEntry[] entryRefs = jalview.util.DBRefUtils.selectRefs( - entry.getDBRef(), new String[] { dbSource }); + entry.getDBRefs(), new String[] { dbSource }); if (entryRefs == null) { System.err @@ -591,8 +591,8 @@ public class DBRefFetcher implements Runnable // no existing references // TODO: test for legacy where uniprot or EMBL refs exist but no // mappings are made (but content matches retrieved set) - boolean updateRefFrame = sequence.getDBRef() == null - || sequence.getDBRef().length == 0; + boolean updateRefFrame = sequence.getDBRefs() == null + || sequence.getDBRefs().length == 0; // TODO: // verify sequence against the entry sequence @@ -737,7 +737,7 @@ public class DBRefFetcher implements Runnable for (int i = 0; sequencesArray != null && i < sequencesArray.length; i++) { nseq.addElement(sequencesArray[i]); - DBRefEntry dbr[] = sequencesArray[i].getDBRef(); + DBRefEntry dbr[] = sequencesArray[i].getDBRefs(); jalview.datamodel.Mapping map = null; for (int r = 0; (dbr != null) && r < dbr.length; r++) { diff --git a/src/jalview/ws/DasSequenceFeatureFetcher.java b/src/jalview/ws/DasSequenceFeatureFetcher.java index 808d9a0..8faba60 100644 --- a/src/jalview/ws/DasSequenceFeatureFetcher.java +++ b/src/jalview/ws/DasSequenceFeatureFetcher.java @@ -181,7 +181,7 @@ public class DasSequenceFeatureFetcher int refCount = 0; for (int i = 0; i < sequences.length; i++) { - DBRefEntry[] dbref = sequences[i].getDBRef(); + DBRefEntry[] dbref = sequences[i].getDBRefs(); if (dbref != null) { for (int j = 0; j < dbref.length; j++) @@ -638,7 +638,7 @@ public class DasSequenceFeatureFetcher return null; } DBRefEntry[] uprefs = jalview.util.DBRefUtils.selectRefs( - seq.getDBRef(), new String[] { + seq.getDBRefs(), new String[] { // jalview.datamodel.DBRefSource.PDB, jalview.datamodel.DBRefSource.UNIPROT, // jalview.datamodel.DBRefSource.EMBL - not tested on any EMBL coord diff --git a/src/jalview/ws/seqfetcher/ASequenceFetcher.java b/src/jalview/ws/seqfetcher/ASequenceFetcher.java index 8656c25..0fe7275 100644 --- a/src/jalview/ws/seqfetcher/ASequenceFetcher.java +++ b/src/jalview/ws/seqfetcher/ASequenceFetcher.java @@ -171,7 +171,7 @@ public class ASequenceFetcher { rseqs.addElement(seqs[is]); DBRefEntry[] frefs = DBRefUtils.searchRefs(seqs[is] - .getDBRef(), new DBRefEntry(db, null, null)); + .getDBRefs(), new DBRefEntry(db, null, null)); if (frefs != null) { for (DBRefEntry dbr : frefs) diff --git a/test/jalview/analysis/AlignmentUtilsTests.java b/test/jalview/analysis/AlignmentUtilsTests.java index 84b9817..9756849 100644 --- a/test/jalview/analysis/AlignmentUtilsTests.java +++ b/test/jalview/analysis/AlignmentUtilsTests.java @@ -1124,8 +1124,8 @@ public class AlignmentUtilsTests assertEquals("GGGTTT", exon.getSequenceAsString()); assertEquals("dna1|A12345", exon.getName()); - assertEquals(1, exon.getDBRef().length); - DBRefEntry cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + DBRefEntry cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("2", cdsRef.getVersion()); assertEquals("A12345", cdsRef.getAccessionId()); @@ -1195,8 +1195,8 @@ public class AlignmentUtilsTests SequenceI exon = exons.get(0); assertEquals("GGGTTT", exon.getSequenceAsString()); assertEquals("dna1|A12345", exon.getName()); - assertEquals(1, exon.getDBRef().length); - DBRefEntry cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + DBRefEntry cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("2", cdsRef.getVersion()); assertEquals("A12345", cdsRef.getAccessionId()); @@ -1204,8 +1204,8 @@ public class AlignmentUtilsTests exon = exons.get(1); assertEquals("aaaccc", exon.getSequenceAsString()); assertEquals("dna1|A12346", exon.getName()); - assertEquals(1, exon.getDBRef().length); - cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("3", cdsRef.getVersion()); assertEquals("A12346", cdsRef.getAccessionId()); @@ -1213,8 +1213,8 @@ public class AlignmentUtilsTests exon = exons.get(2); assertEquals("aaaTTT", exon.getSequenceAsString()); assertEquals("dna1|A12347", exon.getName()); - assertEquals(1, exon.getDBRef().length); - cdsRef = exon.getDBRef()[0]; + assertEquals(1, exon.getDBRefs().length); + cdsRef = exon.getDBRefs()[0]; assertEquals("EMBLCDS", cdsRef.getSource()); assertEquals("4", cdsRef.getVersion()); assertEquals("A12347", cdsRef.getAccessionId()); diff --git a/test/jalview/util/DBRefUtilsTest.java b/test/jalview/util/DBRefUtilsTest.java index 4a55a0d..7a6dc35 100644 --- a/test/jalview/util/DBRefUtilsTest.java +++ b/test/jalview/util/DBRefUtilsTest.java @@ -137,7 +137,7 @@ public class DBRefUtilsTest { SequenceI seq = new Sequence("Seq1", "ABCD"); DBRefEntry ref = DBRefUtils.parseToDbRef(seq, "EMBL", "1.2", "a7890"); - DBRefEntry[] refs = seq.getDBRef(); + DBRefEntry[] refs = seq.getDBRefs(); assertEquals(1, refs.length); assertSame(ref, refs[0]); assertEquals("EMBL", ref.getSource()); @@ -155,7 +155,7 @@ public class DBRefUtilsTest SequenceI seq = new Sequence("Seq1", "ABCD"); DBRefEntry ref = DBRefUtils.parseToDbRef(seq, "pdb", "1.2", "1WRI A; 7-80;"); - DBRefEntry[] refs = seq.getDBRef(); + DBRefEntry[] refs = seq.getDBRefs(); assertEquals(1, refs.length); assertSame(ref, refs[0]); assertEquals("PDB", ref.getSource()); diff --git a/test/jalview/ws/seqfetcher/DbRefFetcherTest.java b/test/jalview/ws/seqfetcher/DbRefFetcherTest.java index ddd8b33..902498b 100644 --- a/test/jalview/ws/seqfetcher/DbRefFetcherTest.java +++ b/test/jalview/ws/seqfetcher/DbRefFetcherTest.java @@ -166,7 +166,7 @@ public class DbRefFetcherTest FeatureProperties.isCodingFeature(embl.getDbSource(), sfs[0].getType())); assertEquals(embl.getDbSource(), sfs[0].getFeatureGroup()); - DBRefEntry[] dr = DBRefUtils.selectRefs(seq.getDBRef(), + DBRefEntry[] dr = DBRefUtils.selectRefs(seq.getDBRefs(), DBRefSource.PROTEINSEQ); assertNotNull(dr); assertEquals("Expected a single Uniprot cross reference", 1, dr.length); -- 1.7.10.2