return true;
if (entry==null)
return false;
- if ((source!=null && entry.source!=null && source.equals(entry.source))
- &&
- (accessionId!=null && entry.accessionId!=null && accessionId.equals(entry.accessionId))
- &&
- (version!=null && entry.version!=null && version.equals(entry.version))
- &&
+ if (equalRef(entry)
+ &&
((map==null && entry.map==null) || (map!=null && entry.map!=null && map.equals(entry.map)))) {
return true;
}
return false;
}
+ /**
+ * test for similar DBRef attributes, except for the map object.
+ * @param entry
+ * @return true if source, accession and version are equal with those of entry
+ */
+ public boolean equalRef(DBRefEntry entry)
+ {
+ if (entry==null)
+ {
+ return false;
+ }
+ if (entry==this)
+ return true;
+ if ((source!=null && entry.source!=null && source.equals(entry.source))
+ &&
+ (accessionId!=null && entry.accessionId!=null && accessionId.equals(entry.accessionId))
+ &&
+ (version!=null && entry.version!=null && version.equals(entry.version))
+ )
+ {
+ return true;
+ }
+ return false;
+ }
public String getSource()
{
return source;
for(i=0; i<iSize; i++)
{
- if(dbrefs[i].equals(entry))
+ if(dbrefs[i].equalRef(entry))
{
+ if (entry.getMap()!=null)
+ {
+ if (dbrefs[i].getMap()==null)
+ {
+ // overwrite with 'superior' entry that contains a mapping.
+ dbrefs[i] = entry;
+ }
+ }
return;
}
}
public DBRefEntry[] getDBRef();
+ /**
+ * add the given entry to the list of DBRefs for this sequence,
+ * or replace a similar one if entry contains a map object
+ * and the existing one doesnt.
+ * @param entry
+ */
public void addDBRef(DBRefEntry entry);
public void addSequenceFeature(SequenceFeature sf);
jalview.datamodel.DBRefSource.UNIPROT))
{
ref.setMap(map);
- /*if (map.getTo()!=null)
+ if (map!=null && map.getTo()!=null)
{
- map.getTo().setName(map.getTo().getName()+"|"+ref.getSource()+"|"+ref.getAccessionId());
- }*/
+ map.getTo().addDBRef(new DBRefEntry(ref.getSource(), ref.getVersion(), ref.getAccessionId())); // don't copy map over.
+ }
}
if (product != null)
{
DBRefEntry pref = new DBRefEntry(ref.getSource(), ref
- .getVersion(), ref.getAccessionId());
+ .getVersion(), ref.getAccessionId());
pref.setMap(null); // reference is direct
product.addDBRef(pref);
// Add converse mapping reference