import jalview.analysis.AlignSeq;
import jalview.api.DBRefEntryI;
+import jalview.util.DBRefUtils;
+import jalview.util.MapList;
import jalview.util.StringUtils;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
String vamsasId;
- DBRefEntryI sourceDBRef;
-
DBRefEntry[] dbrefs;
RNA rna;
seq.getEnd());
}
description = seq.getDescription();
- sourceDBRef = seq.getSourceDBRef() == null ? null : new DBRefEntry(
- seq.getSourceDBRef());
if (seq != datasetSequence)
{
setDatasetSequence(seq.getDatasetSequence());
@Override
public PDBEntry getPDBEntry(String pdbIdStr)
{
- if (getDatasetSequence() == null
- || getDatasetSequence().getAllPDBEntries() == null)
+ if (getDatasetSequence() != null)
+ {
+ return getDatasetSequence().getPDBEntry(pdbIdStr);
+ }
+ if (pdbIds == null)
{
return null;
}
- List<PDBEntry> entries = getDatasetSequence().getAllPDBEntries();
+ List<PDBEntry> entries = getAllPDBEntries();
for (PDBEntry entry : entries)
{
if (entry.getId().equalsIgnoreCase(pdbIdStr))
return null;
}
- @Override
- public void setSourceDBRef(DBRefEntryI dbRef)
- {
- this.sourceDBRef = dbRef;
- }
@Override
- public DBRefEntryI getSourceDBRef()
+ public List<DBRefEntry> getPrimaryDBRefs()
{
- return this.sourceDBRef;
+ if (datasetSequence!=null)
+ {
+ return datasetSequence.getPrimaryDBRefs();
+ }
+ if (dbrefs==null || dbrefs.length==0)
+ {
+ return Collections.emptyList();
+ }
+ synchronized (dbrefs)
+ {
+ List<DBRefEntry> primaries = new ArrayList<DBRefEntry>();
+ DBRefEntry[] tmp = new DBRefEntry[1];
+ for (DBRefEntry ref : dbrefs)
+ {
+ if (!ref.isPrimary())
+ {
+ continue;
+ }
+ if (ref.hasMap())
+ {
+ MapList mp = ref.getMap().getMap();
+ if (mp.getFromLowest() > start || mp.getFromHighest() < end)
+ {
+ // map only involves a subsequence, so cannot be primary
+ continue;
+ }
+ }
+ // whilst it looks like it is a primary ref, we also sanity check type
+ if (DBRefUtils.getCanonicalName(DBRefSource.PDB).equals(
+ DBRefUtils.getCanonicalName(ref.getSource())))
+ {
+ // PDB dbrefs imply there should be a PDBEntry associated
+ // TODO: tighten PDB dbrefs
+ // formally imply Jalview has actually downloaded and
+ // parsed the pdb file. That means there should be a cached file
+ // handle on the PDBEntry, and a real mapping between sequence and
+ // extracted sequence from PDB file
+ PDBEntry pdbentry = getPDBEntry(ref.getAccessionId());
+ if (pdbentry != null && pdbentry.getFile() != null)
+ {
+ primaries.add(ref);
+ }
+ continue;
+ }
+ // check standard protein or dna sources
+ tmp[0] = ref;
+ DBRefEntry[] res = DBRefUtils.selectDbRefs(!isProtein(), tmp);
+ if (res != null && res[0] == tmp[0])
+ {
+ primaries.add(ref);
+ continue;
+ }
+ }
+ return primaries;
+ }
}
}