From d1aade87dce0266a471dfa1e96d5a94499d5d262 Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Wed, 14 Oct 2015 12:24:40 +0100 Subject: [PATCH] JAL-1926 added supporting model changes to enable saving sourceDBRef data for sequences --- src/jalview/analysis/AlignSeq.java | 1 + src/jalview/datamodel/DBRefEntry.java | 27 ++++++++---- src/jalview/datamodel/Sequence.java | 46 ++++++++++++++++++++ src/jalview/datamodel/SequenceI.java | 6 +++ .../structure/StructureSelectionManager.java | 2 +- 5 files changed, 73 insertions(+), 9 deletions(-) diff --git a/src/jalview/analysis/AlignSeq.java b/src/jalview/analysis/AlignSeq.java index 3ca3d90..527b1ff 100755 --- a/src/jalview/analysis/AlignSeq.java +++ b/src/jalview/analysis/AlignSeq.java @@ -948,6 +948,7 @@ public class AlignSeq public static void displayMatrix(Graphics g, int[][] mat, int n, int m, int psize) { + // TODO method dosen't seem to be referenced anywhere delete?? int max = -1000; int min = 1000; diff --git a/src/jalview/datamodel/DBRefEntry.java b/src/jalview/datamodel/DBRefEntry.java index 0581845..0d6f68d 100755 --- a/src/jalview/datamodel/DBRefEntry.java +++ b/src/jalview/datamodel/DBRefEntry.java @@ -20,7 +20,9 @@ */ package jalview.datamodel; -public class DBRefEntry +import jalview.api.DBRefEntryI; + +public class DBRefEntry implements DBRefEntryI { String source = "", version = "", accessionId = ""; @@ -98,7 +100,8 @@ public class DBRefEntry * @param entry * @return true if source, accession and version are equal with those of entry */ - public boolean equalRef(DBRefEntry entry) + @Override + public boolean equalRef(DBRefEntryI entry) { if (entry == null) { @@ -108,28 +111,32 @@ public class DBRefEntry { return true; } - if ((source != null && entry.source != null && source - .equalsIgnoreCase(entry.source)) - && (accessionId != null && entry.accessionId != null && accessionId - .equalsIgnoreCase(entry.accessionId)) - && (version != null && entry.version != null && version - .equalsIgnoreCase(entry.version))) + if (entry != null + && (source != null && entry.getSource() != null && source + .equalsIgnoreCase(entry.getSource())) + && (accessionId != null && entry.getAccessionId() != null && accessionId + .equalsIgnoreCase(entry.getAccessionId())) + && (version != null && entry.getVersion() != null && version + .equalsIgnoreCase(entry.getVersion()))) { return true; } return false; } + @Override public String getSource() { return source; } + @Override public String getVersion() { return version; } + @Override public String getAccessionId() { return accessionId; @@ -139,6 +146,7 @@ public class DBRefEntry * @param accessionId * the accessionId to set */ + @Override public void setAccessionId(String accessionId) { this.accessionId = accessionId; @@ -148,6 +156,7 @@ public class DBRefEntry * @param source * the source to set */ + @Override public void setSource(String source) { this.source = source; @@ -157,6 +166,7 @@ public class DBRefEntry * @param version * the version to set */ + @Override public void setVersion(String version) { this.version = version; @@ -194,6 +204,7 @@ public class DBRefEntry + ((accessionId != null) ? accessionId : ""); } + @Override public String toString() { return getSrcAccString(); diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index c7581d8..9f65f71 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -21,6 +21,7 @@ package jalview.datamodel; import jalview.analysis.AlignSeq; +import jalview.api.DBRefEntryI; import jalview.util.StringUtils; import java.util.ArrayList; @@ -55,6 +56,8 @@ public class Sequence extends ASequence implements SequenceI String vamsasId; + DBRefEntryI sourceDBRef; + DBRefEntry[] dbrefs; RNA rna; @@ -276,11 +279,13 @@ public class Sequence extends ASequence implements SequenceI * @param v * DOCUMENT ME! */ + @Override public void setSequenceFeatures(SequenceFeature[] features) { sequenceFeatures = features; } + @Override public synchronized void addSequenceFeature(SequenceFeature sf) { if (sequenceFeatures == null) @@ -303,6 +308,7 @@ public class Sequence extends ASequence implements SequenceI sequenceFeatures = temp; } + @Override public void deleteFeature(SequenceFeature sf) { if (sequenceFeatures == null) @@ -352,6 +358,7 @@ public class Sequence extends ASequence implements SequenceI * * @return */ + @Override public SequenceFeature[] getSequenceFeatures() { SequenceFeature[] features = sequenceFeatures; @@ -367,6 +374,7 @@ public class Sequence extends ASequence implements SequenceI return features; } + @Override public void addPDBId(PDBEntry entry) { if (pdbIds == null) @@ -419,6 +427,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public String getDisplayId(boolean jvsuffix) { StringBuffer result = new StringBuffer(name); @@ -436,6 +445,7 @@ public class Sequence extends ASequence implements SequenceI * @param name * DOCUMENT ME! */ + @Override public void setName(String name) { this.name = name; @@ -447,6 +457,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public String getName() { return this.name; @@ -458,6 +469,7 @@ public class Sequence extends ASequence implements SequenceI * @param start * DOCUMENT ME! */ + @Override public void setStart(int start) { this.start = start; @@ -468,6 +480,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public int getStart() { return this.start; @@ -479,6 +492,7 @@ public class Sequence extends ASequence implements SequenceI * @param end * DOCUMENT ME! */ + @Override public void setEnd(int end) { this.end = end; @@ -489,6 +503,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public int getEnd() { return this.end; @@ -499,6 +514,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public int getLength() { return this.sequence.length; @@ -510,22 +526,26 @@ public class Sequence extends ASequence implements SequenceI * @param seq * DOCUMENT ME! */ + @Override public void setSequence(String seq) { this.sequence = seq.toCharArray(); checkValidRange(); } + @Override public String getSequenceAsString() { return new String(sequence); } + @Override public String getSequenceAsString(int start, int end) { return new String(getSequence(start, end)); } + @Override public char[] getSequence() { return sequence; @@ -536,6 +556,7 @@ public class Sequence extends ASequence implements SequenceI * * @see jalview.datamodel.SequenceI#getSequence(int, int) */ + @Override public char[] getSequence(int start, int end) { if (start < 0) @@ -596,6 +617,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public char getCharAt(int i) { if (i < sequence.length) @@ -614,6 +636,7 @@ public class Sequence extends ASequence implements SequenceI * @param desc * DOCUMENT ME! */ + @Override public void setDescription(String desc) { this.description = desc; @@ -624,6 +647,7 @@ public class Sequence extends ASequence implements SequenceI * * @return DOCUMENT ME! */ + @Override public String getDescription() { return this.description; @@ -634,6 +658,7 @@ public class Sequence extends ASequence implements SequenceI * * @see jalview.datamodel.SequenceI#findIndex(int) */ + @Override public int findIndex(int pos) { // returns the alignment position for a residue @@ -686,6 +711,7 @@ public class Sequence extends ASequence implements SequenceI * @return int[SequenceI.getEnd()-SequenceI.getStart()+1] or null if no * residues in SequenceI object */ + @Override public int[] gapMap() { String seq = jalview.analysis.AlignSeq.extractGaps( @@ -973,6 +999,7 @@ public class Sequence extends ASequence implements SequenceI annotation.setSequenceRef(this); } + @Override public void removeAlignmentAnnotation(AlignmentAnnotation annotation) { if (this.annotation != null) @@ -1040,6 +1067,7 @@ public class Sequence extends ASequence implements SequenceI * * @see jalview.datamodel.SequenceI#createDatasetSequence() */ + @Override public SequenceI createDatasetSequence() { if (datasetSequence == null) @@ -1078,6 +1106,7 @@ public class Sequence extends ASequence implements SequenceI * jalview.datamodel.SequenceI#setAlignmentAnnotation(AlignmmentAnnotation[] * annotations) */ + @Override public void setAlignmentAnnotation(AlignmentAnnotation[] annotations) { if (annotation != null) @@ -1250,6 +1279,7 @@ public class Sequence extends ASequence implements SequenceI * @return The index (zero-based) on this sequence in the MSA. It returns * {@code -1} if this information is not available. */ + @Override public int getIndex() { return index; @@ -1263,16 +1293,19 @@ public class Sequence extends ASequence implements SequenceI * position for this sequence. This value is zero-based (zero for * this first sequence) */ + @Override public void setIndex(int value) { index = value; } + @Override public void setRNA(RNA r) { rna = r; } + @Override public RNA getRNA() { return rna; @@ -1297,6 +1330,7 @@ public class Sequence extends ASequence implements SequenceI return result; } + @Override public String toString() { return getDisplayId(false); @@ -1321,4 +1355,16 @@ public class Sequence extends ASequence implements SequenceI return null; } + @Override + public void setSourceDBRef(DBRefEntryI dbRef) + { + this.sourceDBRef = dbRef; + } + + @Override + public DBRefEntryI getSourceDBRef() + { + return this.sourceDBRef; + } + } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index 0e649c0..49b0e4d 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -20,6 +20,8 @@ */ package jalview.datamodel; +import jalview.api.DBRefEntryI; + import java.util.List; import java.util.Vector; @@ -429,4 +431,8 @@ public interface SequenceI extends ASequenceI * @return */ public PDBEntry getPDBEntry(String pdbId); + + public void setSourceDBRef(DBRefEntryI dbRef); + + public DBRefEntryI getSourceDBRef(); } diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 26b7d48..59d8631 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -485,8 +485,8 @@ public class StructureSelectionManager 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(" "); -- 1.7.10.2