return false;
}
String name = seq2.getName();
- final DBRefEntry[] xrefs = seq1.getDBRefs();
+ final List<DBRefEntry> xrefs = seq1.getDBRefs();
if (xrefs != null)
{
- for (DBRefEntry xref : xrefs)
+ for (int ix = 0, nx = xrefs.size(); ix < nx; ix++)
{
+ DBRefEntry xref = xrefs.get(ix);
String xrefName = xref.getSource() + "|" + xref.getAccessionId();
// case-insensitive test, consistent with DBRefEntry.equalRef()
if (xrefName.equalsIgnoreCase(name))
// need to
// synthesize an xref.
- for (DBRefEntry primRef : dnaDss.getPrimaryDBRefs())
+ List<DBRefEntry> primrefs = dnaDss.getPrimaryDBRefs();
+ for (int ip = 0, np = primrefs.size(); ip < np; ip++)
{
+ DBRefEntry primRef = primrefs.get(ip);
/*
* create a cross-reference from CDS to the source sequence's
* primary reference and vice versa
dnaSeq.addDBRef(new DBRefEntry(source, version, cdsSeq
.getName(), new Mapping(cdsSeqDss, dnaToCdsMap)));
-
// problem here is that the cross-reference is synthesized -
// cdsSeq.getName() may be like 'CDS|dnaaccession' or
// 'CDS|emblcdsacc'
.getInverse()));
proteinProduct.addDBRef(proteinToCdsRef);
}
-
/*
* transfer any features on dna that overlap the CDS
*/
List<DBRefEntry> direct = new ArrayList<>();
HashSet<String> directSources = new HashSet<>();
- if (contig.getDBRefs() != null)
+ List<DBRefEntry> refs = contig.getDBRefs();
+ if (refs != null)
{
- for (DBRefEntry dbr : contig.getDBRefs())
+ for (int ib = 0, nb = refs.size(); ib < nb; ib++)
{
- if (dbr.hasMap() && dbr.getMap().getMap().isTripletMap())
+ DBRefEntry dbr = refs.get(ib);
+ MapList map;
+ if (dbr.hasMap() && (map = dbr.getMap().getMap()).isTripletMap())
{
- MapList map = dbr.getMap().getMap();
// check if map is the CDS mapping
if (mapping.getMap().equals(map))
{
}
}
}
- DBRefEntry[] onSource = DBRefUtils.selectRefs(
+ List<DBRefEntry> onSource = DBRefUtils.selectRefs(
proteinProduct.getDBRefs(),
directSources.toArray(new String[0]));
List<DBRefEntry> propagated = new ArrayList<>();
// and generate appropriate mappings
- for (DBRefEntry cdsref : direct)
+ for (int ic = 0, nc = direct.size(); ic < nc; ic++)
{
+ DBRefEntry cdsref = direct.get(ic);
+ Mapping m = cdsref.getMap();
// clone maplist and mapping
MapList cdsposmap = new MapList(
Arrays.asList(new int[][]
{ new int[] { cdsSeq.getStart(), cdsSeq.getEnd() } }),
- cdsref.getMap().getMap().getToRanges(), 3, 1);
- Mapping cdsmap = new Mapping(cdsref.getMap().getTo(),
- cdsref.getMap().getMap());
+ m.getMap().getToRanges(), 3, 1);
+ Mapping cdsmap = new Mapping(m.getTo(),m.getMap());
// create dbref
DBRefEntry newref = new DBRefEntry(cdsref.getSource(),
SequenceIdMatcher matcher = new SequenceIdMatcher(seqs);
if (xrefs != null)
{
- for (SequenceI xref : xrefs)
+ // BH 2019.01.25 streamlined this triply nested loop to remove all iterators
+
+ for (int ix = 0, nx = xrefs.length; ix < nx; ix++)
{
- DBRefEntry[] dbrefs = xref.getDBRefs();
+ SequenceI xref = xrefs[ix];
+ List<DBRefEntry> dbrefs = xref.getDBRefs();
if (dbrefs != null)
{
- for (DBRefEntry dbref : dbrefs)
+ for (int ir = 0, nir = dbrefs.size(); ir < nir; ir++)
{
- if (dbref.getMap() == null || dbref.getMap().getTo() == null
- || dbref.getMap().getTo().isProtein() != isProtein)
+ DBRefEntry dbref = dbrefs.get(ir);
+ Mapping map = dbref.getMap();
+ SequenceI mto;
+ if (map == null || (mto = map.getTo()) == null
+ || mto.isProtein() != isProtein)
{
continue;
}
- SequenceI mappedTo = dbref.getMap().getTo();
+ SequenceI mappedTo = mto;
SequenceI match = matcher.findIdMatch(mappedTo);
if (match == null)
{
/*
* first find seq's xrefs (dna-to-peptide or peptide-to-dna)
*/
- DBRefEntry[] rfs = DBRefUtils.selectDbRefs(!fromDna, seq.getDBRefs());
+ List<DBRefEntry> rfs = DBRefUtils.selectDbRefs(!fromDna, seq.getDBRefs());
addXrefsToSources(rfs, sources);
if (dataset != null)
{
/*
* find sequence's direct (dna-to-dna, peptide-to-peptide) xrefs
*/
- DBRefEntry[] lrfs = DBRefUtils.selectDbRefs(fromDna, seq.getDBRefs());
+ List<DBRefEntry> lrfs = DBRefUtils.selectDbRefs(fromDna, seq.getDBRefs());
List<SequenceI> foundSeqs = new ArrayList<>();
/*
*/
for (SequenceI rs : foundSeqs)
{
- DBRefEntry[] xrs = DBRefUtils.selectDbRefs(!fromDna,
+ List<DBRefEntry> xrs = DBRefUtils.selectDbRefs(!fromDna,
rs.getDBRefs());
addXrefsToSources(xrs, sources);
}
* @param xrefs
* @param sources
*/
- void addXrefsToSources(DBRefEntry[] xrefs, List<String> sources)
+ void addXrefsToSources(List<DBRefEntry> xrefs, List<String> sources)
{
if (xrefs != null)
{
dss = dss.getDatasetSequence();
}
boolean found = false;
- DBRefEntry[] xrfs = DBRefUtils.selectDbRefs(!fromDna,
+ List<DBRefEntry> xrfs = DBRefUtils.selectDbRefs(!fromDna,
dss.getDBRefs());
// ENST & ENSP comes in to both Protein and nucleotide, so we need to
// filter them
// out later.
- if ((xrfs == null || xrfs.length == 0) && dataset != null)
+ if ((xrfs == null || xrfs.size() == 0) && dataset != null)
{
/*
* found no suitable dbrefs on sequence - look for sequences in the
* alignment which share a dbref with this one
*/
- DBRefEntry[] lrfs = DBRefUtils.selectDbRefs(fromDna,
+ List<DBRefEntry> lrfs = DBRefUtils.selectDbRefs(fromDna,
seq.getDBRefs());
/*
{
// do a bit more work - search for sequences with references matching
// xrefs on this sequence.
- found = searchDataset(fromDna, dss, xref, rseqs, cf, false);
+ found = searchDataset(fromDna, dss, xref, rseqs, cf, false, DBRefUtils.SEARCH_MODE_FULL);
}
if (found)
{
}
private void retrieveCrossRef(List<DBRefEntry> sourceRefs, SequenceI seq,
- DBRefEntry[] xrfs, boolean fromDna, AlignedCodonFrame cf)
+ List<DBRefEntry> xrfs, boolean fromDna, AlignedCodonFrame cf)
{
ASequenceFetcher sftch = SequenceFetcherFactory.getSequenceFetcher();
SequenceI[] retrieved = null;
private void removeAlreadyRetrievedSeqs(List<DBRefEntry> sourceRefs,
boolean fromDna)
{
- DBRefEntry[] dbrSourceSet = sourceRefs.toArray(new DBRefEntry[0]);
- for (SequenceI sq : dataset.getSequences())
+ List<DBRefEntry> dbrSourceSet = new ArrayList<DBRefEntry>(sourceRefs);
+ List<SequenceI> dsSeqs = dataset.getSequences();
+ for (int ids = dsSeqs.size(); --ids >= 0;)
{
+ SequenceI sq = dsSeqs.get(ids);
boolean dupeFound = false;
// !fromDna means we are looking only for nucleotide sequences, not
// protein
if (sq.isProtein() == fromDna)
{
- for (DBRefEntry dbr : sq.getPrimaryDBRefs())
+ List<DBRefEntry> sqdbrefs = sq.getPrimaryDBRefs();
+ for (int idb = sqdbrefs.size(); --idb >= 0;)
{
- for (DBRefEntry found : DBRefUtils.searchRefs(dbrSourceSet, dbr))
+ DBRefEntry dbr = sqdbrefs.get(idb);
+ List<DBRefEntry> searchrefs = DBRefUtils.searchRefs(dbrSourceSet, dbr, DBRefUtils.SEARCH_MODE_FULL);
+ for (int isr = searchrefs.size(); --isr >= 0;)
{
- sourceRefs.remove(found);
+ sourceRefs.remove(searchrefs.get(isr));
dupeFound = true;
}
}
if (dupeFound)
{
// rebuild the search array from the filtered sourceRefs list
- dbrSourceSet = sourceRefs.toArray(new DBRefEntry[0]);
+ dbrSourceSet.clear();
+ dbrSourceSet.addAll(sourceRefs);
}
}
}
* sourceSequence
*/
boolean imported = false;
- DBRefEntry[] dbr = retrievedSequence.getDBRefs();
+ List<DBRefEntry> dbr = retrievedSequence.getDBRefs();
if (dbr != null)
{
- for (DBRefEntry dbref : dbr)
+ for (int ib = 0, nb = dbr.size(); ib < nb; ib++)
{
+
+ DBRefEntry dbref = dbr.get(ib);
SequenceI matched = findInDataset(dbref);
if (matched == sourceSequence)
{
Mapping map = dbref.getMap();
if (map != null)
{
- if (map.getTo() != null && map.getMap() != null)
+ SequenceI ms = map.getTo();
+ if (ms != null && map.getMap() != null)
{
- if (map.getTo() == sourceSequence)
+ if (ms == sourceSequence)
{
// already called to import once, and most likely this sequence
// already imported !
/*
* sequence is new to dataset, so save a reference so it can be added.
*/
- newDsSeqs.add(map.getTo());
+ newDsSeqs.add(ms);
continue;
}
{
// compare ms with dss and replace with dss in mapping
// if map is congruent
- SequenceI ms = map.getTo();
// TODO findInDataset requires exact sequence match but
// 'congruent' test is only for the mapped part
// maybe not a problem in practice since only ENA provide a
+ matched.getName();
System.out.println(msg);
- DBRefEntry[] toRefs = map.getTo().getDBRefs();
+ List<DBRefEntry> toRefs = map.getTo().getDBRefs();
if (toRefs != null)
{
/*
{
return;
}
- DBRefEntry[] dbrefs = mapTo.getDBRefs();
+ List<DBRefEntry> dbrefs = mapTo.getDBRefs();
if (dbrefs == null)
{
return;
{
// first check primary refs.
List<DBRefEntry> match = DBRefUtils.searchRefs(
- seq.getPrimaryDBRefs().toArray(new DBRefEntry[0]), template);
+ seq.getPrimaryDBRefs(), template, DBRefUtils.SEARCH_MODE_FULL);
if (match != null && match.size() == 1 && sameSequence(seq, dss))
{
return seq;
* @param retrieved
* @param acf
*/
- void updateDbrefMappings(SequenceI mapFrom, DBRefEntry[] xrefs,
+ void updateDbrefMappings(SequenceI mapFrom, List<DBRefEntry> xrefs,
SequenceI[] retrieved, AlignedCodonFrame acf, boolean fromDna)
{
SequenceIdMatcher idMatcher = new SequenceIdMatcher(retrieved);
* @return true if matches were found.
*/
private boolean searchDatasetXrefs(boolean fromDna, SequenceI sequenceI,
- DBRefEntry[] lrfs, List<SequenceI> foundSeqs,
+ List<DBRefEntry> lrfs, List<SequenceI> foundSeqs,
AlignedCodonFrame cf)
{
boolean found = false;
{
return false;
}
- for (int i = 0; i < lrfs.length; i++)
+ for (int i = 0, n = lrfs.size(); i < n; i++)
{
- DBRefEntry xref = new DBRefEntry(lrfs[i]);
- // add in wildcards
- xref.setVersion(null);
- xref.setMap(null);
- found |= searchDataset(fromDna, sequenceI, xref, foundSeqs, cf,
- false);
+// DBRefEntry xref = new DBRefEntry(lrfs.get(i));
+// // add in wildcards
+// xref.setVersion(null);
+// xref.setMap(null);
+ found |= searchDataset(fromDna, sequenceI, lrfs.get(i), foundSeqs, cf,
+ false, DBRefUtils.SEARCH_MODE_NO_MAP_NO_VERSION);
}
return found;
}
* sequenceI or all the returned sequences (eg a genomic reference
* associated with a locus and one or more transcripts)</li>
* </ul>
+ * @param mode SEARCH_MODE_FULL for all; SEARCH_MODE_NO_MAP_NO_VERSION optional
* @return true if relationship found and sequence added.
*/
boolean searchDataset(boolean fromDna, SequenceI fromSeq, DBRefEntry xrf,
List<SequenceI> foundSeqs, AlignedCodonFrame mappings,
- boolean direct)
+ boolean direct, int mode)
{
boolean found = false;
if (dataset == null)
}
// look for direct or indirect references in common
- DBRefEntry[] poss = nxt.getDBRefs();
+ List<DBRefEntry> poss = nxt.getDBRefs();
List<DBRefEntry> cands = null;
// todo: indirect specifies we select either direct references to nxt
// that match xrf which is indirect to sequenceI, or indirect
// references to nxt that match xrf which is direct to sequenceI
- cands = DBRefUtils.searchRefs(poss, xrf);
+ cands = DBRefUtils.searchRefs(poss, xrf, mode);
// else
// {
// poss = DBRefUtils.selectDbRefs(nxt.isProtein()!fromDna, poss);
for (int gd = 0; gd < selection.length; gd++)
{
SequenceI dna = selection[gd];
- DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(),
+ List<DBRefEntry> dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(),
jalview.datamodel.DBRefSource.DNACODINGDBS);
if (dnarefs != null)
{
// intersect with pep
List<DBRefEntry> mappedrefs = new ArrayList<>();
- DBRefEntry[] refs = dna.getDBRefs();
- for (int d = 0; d < refs.length; d++)
+ List<DBRefEntry> refs = dna.getDBRefs();
+ for (int d = 0, nd = refs.size(); d < nd; d++)
{
- if (refs[d].getMap() != null && refs[d].getMap().getMap() != null
- && refs[d].getMap().getMap().getFromRatio() == 3
- && refs[d].getMap().getMap().getToRatio() == 1)
+ DBRefEntry ref = refs.get(d);
+ if (ref.getMap() != null && ref.getMap().getMap() != null
+ && ref.getMap().getMap().getFromRatio() == 3
+ && ref.getMap().getMap().getToRatio() == 1)
{
- mappedrefs.add(refs[d]); // add translated protein maps
+ mappedrefs.add(ref); // add translated protein maps
}
}
- dnarefs = mappedrefs.toArray(new DBRefEntry[mappedrefs.size()]);
- for (int d = 0; d < dnarefs.length; d++)
+ dnarefs = mappedrefs;//.toArray(new DBRefEntry[mappedrefs.size()]);
+ for (int d = 0, nd = dnarefs.size(); d < nd; d++)
{
- Mapping mp = dnarefs[d].getMap();
+ Mapping mp = dnarefs.get(d).getMap();
if (mp != null)
{
- for (int vc = 0; vc < viscontigs.length; vc += 2)
+ for (int vc = 0, nv = viscontigs.length; vc < nv; vc += 2)
{
int[] mpr = mp.locateMappedRange(viscontigs[vc],
viscontigs[vc + 1]);
private static void transferCodedFeatures(SequenceI dna, SequenceI pep,
MapList map)
{
- DBRefEntry[] dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(),
- DBRefSource.DNACODINGDBS);
- if (dnarefs != null)
- {
- // intersect with pep
- for (int d = 0; d < dnarefs.length; d++)
- {
- Mapping mp = dnarefs[d].getMap();
- if (mp != null)
- {
- }
- }
- }
+ // BH 2019.01.25 nop?
+// List<DBRefEntry> dnarefs = DBRefUtils.selectRefs(dna.getDBRefs(),
+// DBRefSource.DNACODINGDBS);
+// if (dnarefs != null)
+// {
+// // intersect with pep
+// for (int d = 0, nd = dnarefs.size(); d < nd; d++)
+// {
+// Mapping mp = dnarefs.get(d).getMap();
+// if (mp != null)
+// {
+// }
+// }
+// }
for (SequenceFeature sf : dna.getFeatures().getAllFeatures())
{
if (FeatureProperties.isCodingFeature(null, sf.getType()))
dbseq = dbseq.getDatasetSequence();
}
// add in any interesting identifiers
- if (dbseq.getDBRefs() != null)
+ List<DBRefEntry> dbr = dbseq.getDBRefs();
+ if (dbr != null)
{
- DBRefEntry dbr[] = dbseq.getDBRefs();
SeqIdName sid = null;
- for (int r = 0; r < dbr.length; r++)
+ for (int r = 0, nr = dbr.size(); r < nr; r++)
{
- sid = new SeqIdName(dbr[r].getAccessionId());
+ sid = new SeqIdName(dbr.get(r).getAccessionId());
if (!names.containsKey(sid))
{
names.put(sid, seq);
import jalview.structure.StructureImportSettings;
import jalview.urls.IdOrgSettings;
import jalview.util.ColorUtils;
+import jalview.util.Platform;
import jalview.ws.sifts.SiftsSettings;
import java.awt.Color;
}
// LOAD THE AUTHORS FROM THE authors.props file
+ boolean ignore = Platform.isJS();
+ if (!ignore)
try
{
- String authorDetails = /** @j2sNative "xxx" || */
- "jar:"
+ String authorDetails = "jar:"
.concat(Cache.class.getProtectionDomain().getCodeSource()
.getLocation().toString().concat("!/authors.props"));
InputStream in = localJarFileURL.openStream();
applicationProperties.load(in);
in.close();
+
} catch (Exception ex)
{
System.out.println("Error reading author details: " + ex);
- applicationProperties.remove("AUTHORS");
- applicationProperties.remove("AUTHORFNAMES");
- applicationProperties.remove("YEAR");
+ ignore = true;
}
+ if (ignore) {
+ applicationProperties.remove("AUTHORS");
+ applicationProperties.remove("AUTHORFNAMES");
+ applicationProperties.remove("YEAR");
+ }
+
// FIND THE VERSION NUMBER AND BUILD DATE FROM jalview.jar
// MUST FOLLOW READING OF LOCAL PROPERTIES FILE AS THE
// VERSION MAY HAVE CHANGED SINCE LAST USING JALVIEW
+ // BH 2019.01.25 switching to Platform.isJS()
+ ignore = Platform.isJS();
+ if (!ignore)
try
{
- String buildDetails = /** @j2sNative "xxx" || */
- "jar:".concat(Cache.class.getProtectionDomain()
+ String buildDetails = "jar:".concat(Cache.class.getProtectionDomain()
.getCodeSource().getLocation().toString()
.concat("!/.build_properties"));
} catch (Exception ex)
{
System.out.println("Error reading build details: " + ex);
- applicationProperties.remove("VERSION");
+ ignore = true;
+ }
+
+ if (ignore) {
+ applicationProperties.remove("VERSION");
}
String jnlpVersion = System.getProperty("jalview.version");
public static AlignFrame currentAlignFrame;
- /**
- * Answers true if Jalview is running as Javascript, else false. The value is
- * set at compile time.
- *
- * @return
- */
- public static boolean isJS()
- {
- return /** @j2sNative true || */
- false;
- }
+//BH 2019.01.25 moved to Platform
+///**
+// * Answers true if Jalview is running as Javascript, else false. The value is
+// * set at compile time.
+// *
+// * @return
+// */
+//public static boolean isJS()
+//{
+// return /** @j2sNative true || */
+// false;
+//}
static
{
- if (!isJS())
+ if (!Platform.isJS())
{ // BH 2018
// grab all the rights we can the JVM
Policy.setPolicy(new Policy()
void doMain(String[] args)
{
- if (!isJS())
+ if (!Platform.isJS())
{
System.setSecurityManager(null);
}
}
System.out.println("CMD [-open " + file + "] executed successfully!");
- if (!isJS() && !file.startsWith("http://"))
+ if (!Platform.isJS() && !file.startsWith("http://"))
{
if (!(new File(file)).exists())
{
package jalview.datamodel;
import jalview.api.DBRefEntryI;
+import jalview.util.DBRefUtils;
+import jalview.util.MapList;
import java.util.Arrays;
import java.util.List;
String source = "";
- String version = "";
+ String version = "", ucversion;
String accessionId = "";
+
+ String sourceKey;
+
+ String canonicalSourceName;
+
/**
* maps from associated sequence to the database sequence's coordinate system
public DBRefEntry(String source, String version, String accessionId,
Mapping map)
{
- this.source = source.toUpperCase();
- this.version = version;
- this.accessionId = accessionId;
+ // BH 2019.01.25 made these always non-null.
+ // Is there a difference between "" and null for version?
+ // evidence is that source CANNOT be null.
+ setSource(source);
+ setVersion(version);
+ setAccessionId(accessionId);
this.map = map;
}
public DBRefEntry(DBRefEntryI entry)
{
- this((entry.getSource() == null ? "" : new String(entry.getSource())),
- (entry.getVersion() == null ? ""
- : new String(entry.getVersion())),
- (entry.getAccessionId() == null ? ""
- : new String(entry.getAccessionId())),
- (entry.getMap() == null ? null : new Mapping(entry.getMap())));
+ this(entry.getSource(), entry.getVersion(), entry.getAccessionId(), entry.getMap() == null ? null : new Mapping(entry.getMap()));
+// this((entry.getSource() == null ? "" : new String(entry.getSource())),
+// (entry.getVersion() == null ? ""
+// : new String(entry.getVersion())),
+// (entry.getAccessionId() == null ? ""
+// : new String(entry.getAccessionId())),
+// (entry.getMap() == null ? null : new Mapping(entry.getMap())));
}
@Override
{
// TODO should also override hashCode to ensure equal objects have equal
// hashcodes
- if (o == null || !(o instanceof DBRefEntry))
- {
- return false;
- }
- DBRefEntry entry = (DBRefEntry) o;
- if (entry == this)
- {
- return true;
- }
- if (equalRef(entry) && ((map == null && entry.map == null)
- || (map != null && entry.map != null && map.equals(entry.map))))
- {
- return true;
- }
- return false;
+
+
+// if (o == null || !(o instanceof DBRefEntry))
+// {
+// return false;
+// }
+// DBRefEntry entry = (DBRefEntry) o;
+// if (entry == this)
+// {
+// return true;
+// }
+ Mapping em;
+ return (o != null && o instanceof DBRefEntry
+ && (o == this
+ || equalRef((DBRefEntry) o)
+ && (map == null) == ((em = ((DBRefEntry) o).map) == null)
+ && (map == null || map.equals(em))));
+//
+// {
+// return true;
+// }
+// return false;
}
/**
{
return true;
}
+
+ // BH 2019.01.25 source, accessionId, and version cannot be null.
+ // for example, StructureChooser has dbRef.getSource().equalsIgnoreCase...
+
if (entry != null
&& (source != null && entry.getSource() != null
&& source.equalsIgnoreCase(entry.getSource()))
return source;
}
+ public String getSourceKey()
+ {
+ return sourceKey;
+ }
+
@Override
public String getVersion()
{
@Override
public void setAccessionId(String accessionId)
{
- this.accessionId = accessionId;
+ this.accessionId = (accessionId == null ? "" : accessionId).toUpperCase();
}
@Override
public void setSource(String source)
{
- this.source = source;
+ this.source = (source == null ? "" : source).toUpperCase();
+ this.canonicalSourceName = DBRefUtils.getCanonicalName(this.source);
+ this.sourceKey = ";" + canonicalSourceName + ";";
}
@Override
public void setVersion(String version)
{
- this.version = version;
+ this.version = (version == null ? "" : version);
+ this.ucversion = this.version.toUpperCase();
}
@Override
*/
if (map != null)
{
- if (map.getTo() != null)
+ SequenceI mto = map.getTo();
+ if (mto != null)
{
return false;
}
- if (map.getMap().getFromRatio() != map.getMap().getToRatio()
- || map.getMap().getFromRatio() != 1)
+ MapList ml = map.getMap();
+ if (ml.getFromRatio() != ml.getToRatio()
+ || ml.getFromRatio() != 1)
{
return false;
}
// check map is between identical single contiguous ranges
- List<int[]> fromRanges = map.getMap().getFromRanges();
- List<int[]> toRanges = map.getMap().getToRanges();
- if (fromRanges.size() != 1 || toRanges.size() != 1)
+ List<int[]> fromRanges, toRanges;
+ if ((fromRanges = ml.getFromRanges()).size() != 1 || (toRanges = ml.getToRanges()).size() != 1)
{
return false;
}
return false;
}
}
- if (version == null)
+ if (version == null || version == "")
{
// no version string implies the reference has not been verified at all.
return false;
}
// tricky - this test really needs to search the sequence's set of dbrefs to
// see if there is a primary reference that derived this reference.
- String ucv = version.toUpperCase();
- for (String primsrc : Arrays.asList(DBRefSource.allSources()))
+ String[] sources = DBRefSource.allSources();
+ for (int i = sources.length; --i >= 0;)
{
- if (ucv.startsWith(primsrc.toUpperCase()))
+ if (ucversion.startsWith(sources[i])) // BH 2019.01.25 .toUpperCase() unnecessary here for allSources
{
// by convention, many secondary references inherit the primary
// reference's
{
return accessionId != null && accessionId.startsWith(CHROMOSOME + ":");
}
+
+ public Object getCanonicalSourceName() {
+ return canonicalSourceName;
+ }
+
+
}
GENEDB, ENSEMBL, ENSEMBLGENOMES
};
+public static final String PROTEINDBSKEYS, DNACODINGDBSKEYS;
+
+public static final String[] PROMTYPES;
+
+
+public static final int UNIPROT_MASK = 1;
+
+public static final int ENSEMBL_MASK = 2;
+
+public static final int ALL_MASKS = UNIPROT_MASK | ENSEMBL_MASK;
+
+public static final String PDB_CANONICAL_NAME = PDB;
+
+static {
+ // BH 2019.01.25 trying to speed this up
+ String s = ";";
+ for (int i = PROTEINDBS.length; --i >= 0;)
+ s += PROTEINDBS[i] + ";";
+ PROTEINDBSKEYS = s;
+
+ s = ";";
+ for (int i = DNACODINGDBS.length; --i >= 0;)
+ s += DNACODINGDBS[i] + ";";
+ DNACODINGDBSKEYS = s;
+
+ PROMTYPES = new String[] { null, ";" + UNIPROT + ";", ";" + ENSEMBL + ";" , ";" + UNIPROT + ";" + ENSEMBL + ";" };
+}
public static String[] allSourcesFromReflection;
package jalview.datamodel;
import jalview.analysis.AlignSeq;
-import jalview.api.DBRefEntryI;
import jalview.datamodel.features.SequenceFeatures;
import jalview.datamodel.features.SequenceFeaturesI;
import jalview.util.Comparison;
import jalview.util.DBRefUtils;
import jalview.util.MapList;
import jalview.util.StringUtils;
+import jalview.ws.params.InvalidArgumentException;
import java.util.ArrayList;
import java.util.Arrays;
*/
public class Sequence extends ASequence implements SequenceI
{
- SequenceI datasetSequence;
+
+ /**
+ * A subclass that gives us access to modCount, which tracks
+ * whether there have been any changes. We use this to update
+ * @author hansonr
+ *
+ * @param <T>
+ */
+ @SuppressWarnings("serial")
+ protected class DBModList<T> extends ArrayList<DBRefEntry> {
+
+ protected int getModCount() {
+ return modCount;
+ }
+
+ }
+
+SequenceI datasetSequence;
String name;
String vamsasId;
- DBRefEntry[] dbrefs;
+ private DBModList<DBRefEntry> dbrefs; // controlled acces
- RNA rna;
+ /**
+ * a flag to let us know that elements have changed in dbrefs
+ *
+ * @author Bob Hanson
+ */
+ private int refModCount = 0;
+ RNA rna;
+
/**
* This annotation is displayed below the alignment but the positions are tied
* to the residues of this sequence
*/
if (datasetSequence == null)
{
- if (seq.getDBRefs() != null)
+ List<DBRefEntry> dbr = seq.getDBRefs();
+ if (dbr != null)
{
- DBRefEntry[] dbr = seq.getDBRefs();
- for (int i = 0; i < dbr.length; i++)
+ for (int i = 0, n = dbr.size(); i < n; i++)
{
- addDBRef(new DBRefEntry(dbr[i]));
+ addDBRef(new DBRefEntry(dbr.get(i)));
}
}
@Override
public GeneLociI getGeneLoci()
{
- DBRefEntry[] refs = getDBRefs();
+ List<DBRefEntry> refs = getDBRefs();
if (refs != null)
{
for (final DBRefEntry ref : refs)
vamsasId = id;
}
- @Override
- public void setDBRefs(DBRefEntry[] dbref)
+ @SuppressWarnings("deprecation")
+@Override
+ public void setDBRefs(List<DBRefEntry> newDBrefs) throws InvalidArgumentException
{
if (dbrefs == null && datasetSequence != null
&& this != datasetSequence)
{
- datasetSequence.setDBRefs(dbref);
+ datasetSequence.setDBRefs((DBModList<DBRefEntry>)newDBrefs);
return;
}
- dbrefs = dbref;
- if (dbrefs != null)
- {
- DBRefUtils.ensurePrimaries(this);
- }
+ if (newDBrefs != null && !(newDBrefs instanceof DBModList<?>))
+ throw new InvalidArgumentException("DBrefs must have DBModList class");
+
+ dbrefs = (DBModList<DBRefEntry>)newDBrefs;
+ refModCount = 0;
+ }
+
+ @Override
+ public void getDBRefsFrom(SequenceI seq) {
+ try {
+ setDBRefs(seq.getDBRefs());
+ } catch (InvalidArgumentException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
@Override
- public DBRefEntry[] getDBRefs()
+ public List<DBRefEntry> getDBRefs()
{
if (dbrefs == null && datasetSequence != null
&& this != datasetSequence)
return dbrefs;
}
+
@Override
public void addDBRef(DBRefEntry entry)
{
if (dbrefs == null)
{
- dbrefs = new DBRefEntry[0];
+ dbrefs = new DBModList<DBRefEntry>();
}
- for (DBRefEntryI dbr : dbrefs)
+ for (int ib = 0, nb= dbrefs.size(); ib < nb; ib++)
{
- if (dbr.updateFrom(entry))
+ if (dbrefs.get(ib).updateFrom(entry))
{
/*
* found a dbref that either matched, or could be
}
}
- /*
- * extend the array to make room for one more
- */
- // TODO use an ArrayList instead
- int j = dbrefs.length;
- DBRefEntry[] temp = new DBRefEntry[j + 1];
- System.arraycopy(dbrefs, 0, temp, 0, j);
- temp[temp.length - 1] = entry;
-
- dbrefs = temp;
- DBRefUtils.ensurePrimaries(this);
+// /// BH OUCH!
+// /*
+// * extend the array to make room for one more
+// */
+// // TODO use an ArrayList instead
+// int j = dbrefs.length;
+// List<DBRefEntry> temp = new DBRefEntry[j + 1];
+// System.arraycopy(dbrefs, 0, temp, 0, j);
+// temp[temp.length - 1] = entry;
+//
+// dbrefs = temp;
+
+ dbrefs.add(entry);
}
@Override
private int _seqhash = 0;
+private List<DBRefEntry> primaryRefs;
+
/**
* Answers false if the sequence is more than 85% nucleotide (ACGTU), else
* true
// TODO: could merge DBRefs
return datasetSequence.updatePDBIds();
}
- if (dbrefs == null || dbrefs.length == 0)
+ if (dbrefs == null || dbrefs.size() == 0)
{
return false;
}
boolean added = false;
- for (DBRefEntry dbr : dbrefs)
+ for (int ib = 0, nb = dbrefs.size(); ib < nb; ib++)
{
+ DBRefEntry dbr = dbrefs.get(ib);
if (DBRefSource.PDB.equals(dbr.getSource()))
{
/*
}
}
// transfer database references
- DBRefEntry[] entryRefs = entry.getDBRefs();
+ List<DBRefEntry> entryRefs = entry.getDBRefs();
if (entryRefs != null)
{
- for (int r = 0; r < entryRefs.length; r++)
+ for (int r = 0, n = entryRefs.size(); r < n; r++)
{
- DBRefEntry newref = new DBRefEntry(entryRefs[r]);
+ DBRefEntry newref = new DBRefEntry(entryRefs.get(r));
if (newref.getMap() != null && mp != null)
{
// remap ref using our local mapping
return null;
}
+ private List<DBRefEntry> tmpList;
+
@Override
public List<DBRefEntry> getPrimaryDBRefs()
{
{
return datasetSequence.getPrimaryDBRefs();
}
- if (dbrefs == null || dbrefs.length == 0)
+ if (dbrefs == null || dbrefs.size() == 0)
{
return Collections.emptyList();
}
synchronized (dbrefs)
{
- List<DBRefEntry> primaries = new ArrayList<>();
- DBRefEntry[] tmp = new DBRefEntry[1];
- for (DBRefEntry ref : dbrefs)
+ if (refModCount == dbrefs.getModCount() && primaryRefs != null)
+ return primaryRefs;
{
+ refModCount = dbrefs.getModCount();
+ DBRefUtils.ensurePrimaries(this);
+ primaryRefs = null;
+ }
+ List<DBRefEntry> primaries = (primaryRefs == null ? (primaryRefs = new ArrayList<>()) : primaryRefs);
+ primaries.clear();
+ if (tmpList == null) {
+ tmpList = new ArrayList<>();
+ tmpList.add(null); // for replacement
+ }
+ for (int i = 0, n = dbrefs.size(); i < n; i++)
+ {
+ DBRefEntry ref = dbrefs.get(i);
if (!ref.isPrimaryCandidate())
{
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())))
+ if (DBRefSource.PDB_CANONICAL_NAME.equals(ref.getCanonicalSourceName()))
{
// PDB dbrefs imply there should be a PDBEntry associated
// TODO: tighten PDB dbrefs
// 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)
+ if (pdbentry == null || pdbentry.getFile() == null)
{
- primaries.add(ref);
+ continue;
}
- 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;
- }
+ } else {
+ // check standard protein or dna sources
+ tmpList.set(0, ref);
+ List<DBRefEntry> res = DBRefUtils.selectDbRefs(!isProtein(), tmpList);
+ if (res == null || res.get(0) != tmpList.get(0))
+ {
+ continue;
+ }
+ }
+ primaries.add(ref);
}
return primaries;
}
import jalview.renderer.ResidueShader;
import jalview.renderer.ResidueShaderI;
import jalview.schemes.ColourSchemeI;
+import jalview.ws.params.InvalidArgumentException;
import java.awt.Color;
import java.beans.PropertyChangeListener;
for (int i = 0, ipos = 0; i < inorder.length; i++)
{
SequenceI seq = inorder[i];
-
- seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
- if (seqs[ipos] != null)
+ SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes, endRes + 1);
+ if (seqipos != null)
{
- seqs[ipos].setDescription(seq.getDescription());
- seqs[ipos].setDBRefs(seq.getDBRefs());
- seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures());
+ seqipos.setDescription(seq.getDescription());
+ seqipos.getDBRefsFrom(seq);
+ seqipos.setSequenceFeatures(seq.getSequenceFeatures());
if (seq.getDatasetSequence() != null)
{
- seqs[ipos].setDatasetSequence(seq.getDatasetSequence());
+ seqipos.setDatasetSequence(seq.getDatasetSequence());
}
if (seq.getAnnotation() != null)
if (alann != null)
{
boolean found = false;
- for (int pos = 0; pos < alann.length; pos++)
+ for (int pos = 0, np = alann.length; pos < np; pos++)
{
if (alann[pos] == tocopy)
{
newannot.restrict(startRes, endRes);
newannot.setSequenceRef(seqs[ipos]);
newannot.adjustForAlignment();
- seqs[ipos].addAlignmentAnnotation(newannot);
+ seqipos.addAlignmentAnnotation(newannot);
}
}
ipos++;
import jalview.datamodel.features.SequenceFeaturesI;
import jalview.util.MapList;
+import jalview.ws.params.InvalidArgumentException;
import java.util.BitSet;
import java.util.Iterator;
/**
* set the array of Database references for the sequence.
*
+ * BH 2019.01.25 added throw
+ *
* @param dbs
+ * @throws InvalidArgumentException
* @deprecated - use is discouraged since side-effects may occur if DBRefEntry
* set are not normalised.
+ * @throws InvalidArgumentException if the is not one created by Sequence itself
*/
@Deprecated
- public void setDBRefs(DBRefEntry[] dbs);
+ public void setDBRefs(List<DBRefEntry> dbs) throws InvalidArgumentException;
+
+ public List<DBRefEntry> getDBRefs();
- public DBRefEntry[] getDBRefs();
+ public void getDBRefsFrom(SequenceI seq);
/**
* add the given entry to the list of DBRefs for this sequence, or replace a
* @return first residue not contained in regions
*/
public int firstResidueOutsideIterator(Iterator<int[]> it);
+
}
+
import jalview.datamodel.SequenceI;
import jalview.io.gff.SequenceOntologyI;
import jalview.util.JSONUtils;
+import jalview.util.Platform;
import java.io.BufferedReader;
import java.io.IOException;
public AlignmentI getSequenceRecords(String query) throws IOException
{
// TODO: use a vararg String... for getSequenceRecords instead?
+
List<String> queries = new ArrayList<>();
queries.add(query);
SequenceI seq = parseFeaturesJson(queries);
if (seq == null)
return null;
return new Alignment(new SequenceI[] { seq });
+
}
/**
if (rvals == null)
return null;
while (rvals.hasNext())
- {
+ {
try
{
Map<String, Object> obj = (Map<String, Object>) rvals.next();
{
type = SequenceOntologyI.CDS;
}
-
+
String desc = getFirstNotNull(obj, "alleles", "external_name",
JSON_ID);
SequenceFeature sf = new SequenceFeature(type, desc, start, end,
sf.setValue("clinical_significance", clinSig);
seq.addSequenceFeature(sf);
+
} catch (Throwable t)
{
// ignore - keep trying other features
import jalview.schemes.FeatureColour;
import jalview.schemes.FeatureSettingsAdapter;
import jalview.util.MapList;
+import jalview.util.Platform;
import java.awt.Color;
import java.io.UnsupportedEncodingException;
@Override
public AlignmentI getSequenceRecords(String query) throws Exception
{
+
+
+
+ Platform.timeCheck("EG " + query, Platform.TIME_MARK);
+
/*
* convert to a non-duplicated list of gene identifiers
*/
List<String> geneIds = getGeneIds(query);
+
+ Platform.timeCheck("EG genIds " + geneIds.size(), Platform.TIME_MARK);
+
AlignmentI al = null;
for (String geneId : geneIds)
{
/*
* fetch the gene sequence(s) with features and xrefs
*/
+
+ Platform.timeCheck("EG fetch " + geneId, Platform.TIME_MARK);
+
+
AlignmentI geneAlignment = super.getSequenceRecords(geneId);
if (geneAlignment == null)
{
// ensure id has 'correct' case for the Ensembl identifier
geneId = geneAlignment.getSequenceAt(0).getName();
+
+ Platform.timeCheck("EG loci " + geneId, Platform.TIME_MARK);
+
+
findGeneLoci(geneAlignment.getSequenceAt(0), geneId);
+ Platform.timeCheck("EG transcript " + geneId, Platform.TIME_MARK);
+
getTranscripts(geneAlignment, geneId);
}
if (al == null)
al.append(geneAlignment);
}
}
+
+ Platform.timeCheck("EG done", Platform.TIME_MARK);
+
return al;
}
SequenceI genomicSequence = null;
EnsemblFeatures gffFetcher = new EnsemblFeatures(getDomain());
EnsemblFeatureType[] features = getFeaturesToFetch();
+
+ Platform.timeCheck("ESP.getsequencerec1", Platform.TIME_MARK);
+
+
AlignmentI geneFeatures = gffFetcher.getSequenceRecords(accId,
features);
if (geneFeatures != null && geneFeatures.getHeight() > 0)
{
genomicSequence = geneFeatures.getSequenceAt(0);
}
+
+ Platform.timeCheck("ESP.getsequencerec2", Platform.TIME_MARK);
+
if (genomicSequence != null)
{
/*
* transfer features to the query sequence
*/
SequenceI querySeq = alignment.findName(accId, true);
+
+ Platform.timeCheck("ESP.transferfeat", Platform.TIME_MARK);
+
if (transferFeatures(accId, genomicSequence, querySeq))
{
* fetch and map protein product, and add it as a cross-reference
* of the retrieved sequence
*/
+ Platform.timeCheck("ESP.addprotein", Platform.TIME_MARK);
addProteinProduct(querySeq);
}
}
System.err.println(
"Error transferring Ensembl features: " + e.getMessage());
}
+ Platform.timeCheck("ESP.addfeat done", Platform.TIME_MARK);
}
/**
DBRefEntry dbr = new DBRefEntry(getDbSource(),
getEnsemblDataVersion(), proteinSeq.getName(), map);
querySeq.getDatasetSequence().addDBRef(dbr);
- DBRefEntry[] uprots = DBRefUtils.selectRefs(ds.getDBRefs(),
+ List<DBRefEntry> uprots = DBRefUtils.selectRefs(ds.getDBRefs(),
new String[]
{ DBRefSource.UNIPROT });
- DBRefEntry[] upxrefs = DBRefUtils.selectRefs(querySeq.getDBRefs(),
+ List<DBRefEntry> upxrefs = DBRefUtils.selectRefs(querySeq.getDBRefs(),
new String[]
{ DBRefSource.UNIPROT });
if (uprots != null)
*/
protected void getCrossReferences(SequenceI seq)
{
+
+ Platform.timeCheck("ESP. getdataseq ", Platform.TIME_MARK);
+
+
while (seq.getDatasetSequence() != null)
{
seq = seq.getDatasetSequence();
}
+ Platform.timeCheck("ESP. getxref ", Platform.TIME_MARK);
+
EnsemblXref xrefFetcher = new EnsemblXref(getDomain(), getDbSource(),
getEnsemblDataVersion());
List<DBRefEntry> xrefs = xrefFetcher.getCrossReferences(seq.getName());
- for (DBRefEntry xref : xrefs)
+
+ for (int i = 0, n = xrefs.size(); i < n; i++)
{
- seq.addDBRef(xref);
+ Platform.timeCheck("ESP. getxref + " + (i) + "/" + n, Platform.TIME_MARK);
+ // BH 2019.01.25 this next method was taking 174 ms PER addition for a 266-reference example.
+ // DBRefUtils.ensurePrimaries(seq)
+ // was at the end of seq.addDBRef, so executed after ever addition!
+ // This method was moved to seq.getPrimaryDBRefs()
+ seq.addDBRef(xrefs.get(i));
}
+ System.out.println("primaries are " + seq.getPrimaryDBRefs().toString());
/*
* and add a reference to itself
*/
+
+ Platform.timeCheck("ESP. getxref self ", Platform.TIME_MARK);
+
DBRefEntry self = new DBRefEntry(getDbSource(), getEnsemblDataVersion(),
seq.getName());
+
+ Platform.timeCheck("ESP. getxref self add ", Platform.TIME_MARK);
+
seq.addDBRef(self);
+
+ Platform.timeCheck("ESP. seqprox done ", Platform.TIME_MARK);
+
}
/**
* for now, assumes only one sequence returned; refactor if needed
* in future to handle a JSONArray with more than one
*/
+
+ Platform.timeCheck("ENS seqproxy", Platform.TIME_MARK);
Map<String, Object> val = (Map<String, Object>) getJSON(null, ids, -1, MODE_MAP, null);
if (val == null)
return null;
System.err.println("Error processing JSON response: " + e.toString());
// ignore
}
+ Platform.timeCheck("ENS seqproxy2", Platform.TIME_MARK);
return result;
}
*/
package jalview.fts.service.pdb;
-import jalview.bin.Jalview;
import jalview.datamodel.SequenceI;
import jalview.fts.api.FTSData;
import jalview.fts.api.FTSDataColumnI;
import jalview.fts.core.FTSRestResponse;
import jalview.util.JSONUtils;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.net.URI;
import java.util.ArrayList;
// different from the ones in Java yet still allow this to be correct for Java
Client client;
Class<ClientResponse> clientResponseClass;
- if (Jalview.isJS())
+ if (Platform.isJS())
{
// JavaScript only -- coerce types to Java types for Java
client = (Client) (Object) new jalview.javascript.web.Client();
package jalview.fts.service.uniprot;
import jalview.bin.Cache;
-import jalview.bin.Jalview;
import jalview.fts.api.FTSData;
import jalview.fts.api.FTSDataColumnI;
import jalview.fts.api.FTSRestClientI;
import jalview.fts.core.FTSRestRequest;
import jalview.fts.core.FTSRestResponse;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.util.ArrayList;
import java.util.Collection;
// Java
Client client;
Class<ClientResponse> clientResponseClass;
- if (Jalview.isJS())
+ if (Platform.isJS())
{
// JavaScript only -- coerce types to Java types for Java
client = (Client) (Object) new jalview.javascript.web.Client();
throw new Exception(errorMessage);
}
- int xTotalResults = Jalview.isJS() ? 1
+ int xTotalResults = Platform.isJS() ? 1
: Integer.valueOf(clientResponse.getHeaders()
.get("X-Total-Results").get(0));
clientResponse = null;
import jalview.schemes.TCoffeeColourScheme;
import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.ViewportRanges;
import jalview.ws.DBRefFetcher;
{ contents.toString() });
contents = null;
- if (Jalview.isJS())
+ if (Platform.isJS())
{
JLabel textLabel = new JLabel();
textLabel.setText(content);
*/
String[] divisionsArray = ensemblDivisions
.toArray(new String[ensemblDivisions.size()]);
- DBRefEntry[] seqRefs = seq.getDBRefs();
- DBRefEntry[] directEnsemblRefs = DBRefUtils.selectRefs(seqRefs,
+ List<DBRefEntry> seqRefs = seq.getDBRefs();
+ List<DBRefEntry> directEnsemblRefs = DBRefUtils.selectRefs(seqRefs,
divisionsArray);
if (directEnsemblRefs != null)
{
{
if (dbref.getMap() != null && dbref.getMap().getTo() != null)
{
- DBRefEntry[] dbrefs = dbref.getMap().getTo().getDBRefs();
- DBRefEntry[] indirectEnsemblRefs = DBRefUtils.selectRefs(dbrefs,
+ List<DBRefEntry> dbrefs = dbref.getMap().getTo().getDBRefs();
+ List<DBRefEntry> indirectEnsemblRefs = DBRefUtils.selectRefs(dbrefs,
divisionsArray);
if (indirectEnsemblRefs != null)
{
* are spawned off as threads rather than waited for during this constructor.
*/
instance = this;
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
doVamsasClientCheck();
}
// getContentPane().add(sp, BorderLayout.CENTER);
// BH 2018 - just an experiment to try unclipped JInternalFrames.
- if (Jalview.isJS())
+ if (Platform.isJS())
{
getRootPane().putClientProperty("swingjs.overflow.hidden", "false");
}
*/
JComponent history;
String urlBase = "http://www.";
- if (Jalview.isJS())
+ if (Platform.isJS())
{
history = new JTextField(urlBase, 35);
}
@Override
public void run()
{
- String url = Jalview.isJS() ? ((JTextField) history).getText()
+ String url = Platform.isJS() ? ((JTextField) history).getText()
: ((JComboBox<String>) history).getSelectedItem()
.toString();
{
try
{
- if (Jalview.isJS())
+ if (Platform.isJS())
{
BrowserLauncher.openURL("http://www.jalview.org/help.html");
}
import jalview.api.FeatureColourI;
import jalview.api.FeatureSettingsControllerI;
-import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
import jalview.datamodel.features.FeatureMatcher;
* variable colour and filters dialog
*/
chooser = new FeatureTypeSettings(fr, type);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
chooser.setRequestFocusEnabled(true);
chooser.requestFocus();
*/
package jalview.gui;
-import jalview.bin.Jalview;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceGroup;
void startScrolling(boolean up)
{
scrollThread = new ScrollThread(up);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
/*
* Java - run in a new thread
import jalview.util.ImageMaker;
import jalview.util.ImageMaker.TYPE;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.awt.Component;
import java.awt.Graphics;
String renderStyle = Cache.getDefault(
imageType.getName() + "_RENDERING",
LineartOptions.PROMPT_EACH_TIME);
- if (Jalview.isJS())
+ if (Platform.isJS())
{
renderStyle = "Text";
}
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
import jalview.datamodel.GraphLine;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.RnaViewerModel;
vamsasSeq.setName(jds.getName());
vamsasSeq.setSequence(jds.getSequenceAsString());
vamsasSeq.setDescription(jds.getDescription());
- jalview.datamodel.DBRefEntry[] dbrefs = null;
+ List<DBRefEntry> dbrefs = null;
if (jds.getDatasetSequence() != null)
{
vamsasSeq.setDsseqid(seqHash(jds.getDatasetSequence()));
}
if (dbrefs != null)
{
- for (int d = 0; d < dbrefs.length; d++)
+ for (int d = 0, n = dbrefs.size(); d < n; d++)
{
DBRef dbref = new DBRef();
- dbref.setSource(dbrefs[d].getSource());
- dbref.setVersion(dbrefs[d].getVersion());
- dbref.setAccessionId(dbrefs[d].getAccessionId());
- if (dbrefs[d].hasMap())
+ DBRefEntry e = dbrefs.get(d);
+ dbref.setSource(e.getSource());
+ dbref.setVersion(e.getVersion());
+ dbref.setAccessionId(e.getAccessionId());
+ if (e.hasMap())
{
- Mapping mp = createVamsasMapping(dbrefs[d].getMap(), parentseq,
+ Mapping mp = createVamsasMapping(e.getMap(), parentseq,
jds, recurse);
dbref.setMapping(mp);
}
package jalview.gui;
-import jalview.bin.Jalview;
+import jalview.util.Platform;
import jalview.util.dialogrunner.DialogRunnerI;
import java.awt.Component;
public JvOptionPane(final Component parent)
{
- this.parentComponent = Jalview.isJS() ? this : parent;
+ this.parentComponent = Platform.isJS() ? this : parent;
}
public static int showConfirmDialog(Component parentComponent,
String prefix = "";
// JavaScript only
- if (Jalview.isJS())
+ if (Platform.isJS())
{
switch (messageType)
{
* In Java, the response is returned to this thread and handled here;
* (for Javascript, see propertyChange)
*/
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
handleResponse(response);
}
yesNoCancelOption, questionMessage, icon, options,
initresponse);
}
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
handleResponse(response);
}
import jalview.analysis.AlignmentUtils;
import jalview.analysis.Conservation;
import jalview.bin.Cache;
-import jalview.bin.Jalview;
import jalview.commands.ChangeCaseCommand;
import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
import jalview.util.GroupUrlLink;
import jalview.util.GroupUrlLink.UrlStringTooLongException;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import jalview.util.StringUtils;
import jalview.util.UrlLink;
{
sqi = sqi.getDatasetSequence();
}
- DBRefEntry[] dbr = sqi.getDBRefs();
- if (dbr != null && dbr.length > 0)
+ List<DBRefEntry> dbr = sqi.getDBRefs();
+ int nd;
+ if (dbr != null && (nd = dbr.size()) > 0)
{
- for (int d = 0; d < dbr.length; d++)
+ for (int d = 0; d < nd; d++)
{
- String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
+ DBRefEntry e = dbr.get(d);
+ String src = e.getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
Object[] sarray = commonDbrefs.get(src);
if (sarray == null)
{
if (((String[]) sarray[1])[sq] == null)
{
- if (!dbr[d].hasMap() || (dbr[d].getMap()
+ if (!e.hasMap() || (e.getMap()
.locateMappedRange(start, end) != null))
{
- ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
+ ((String[]) sarray[1])[sq] = e.getAccessionId();
((int[]) sarray[0])[0]++;
}
}
String report = contents.toString();
JInternalFrame frame;
- if (Jalview.isJS())
+ if (Platform.isJS())
{
JLabel textLabel = new JLabel();
textLabel.setText(report);
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.bin.Cache;
-import jalview.bin.Jalview;
import jalview.gui.Help.HelpId;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.FileFormatI;
super();
frame = new JInternalFrame();
frame.setContentPane(this);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
wsPrefs = new WsPreferences();
wsTab.add(wsPrefs, BorderLayout.CENTER);
/*
* JalviewJS doesn't support Lineart so force it to Text
*/
- String defaultOption = Jalview.isJS() ? "Text"
+ String defaultOption = Platform.isJS() ? "Text"
: Cache.getDefault(propertyKey, "Prompt each time");
if (defaultOption.equalsIgnoreCase("Text"))
{
Cache.applicationProperties.setProperty("PAD_GAPS",
Boolean.toString(padGaps.isSelected()));
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
wsPrefs.updateAndRefreshWsMenuConfig(false);
}
{
try
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
wsPrefs.updateWsMenuConfig(true);
wsPrefs.refreshWs_actionPerformed(e);
import jalview.api.AlignViewportI;
import jalview.bin.Cache;
-import jalview.bin.Jalview;
import jalview.commands.EditCommand;
import jalview.commands.EditCommand.Action;
import jalview.commands.EditCommand.Edit;
{
scrollThread = new ScrollThread();
scrollThread.setMousePosition(mousePos);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
/*
* Java - run in a new thread
for (String q : queries)
{
- DBRefEntry dbr = new DBRefEntry();
- dbr.setSource(proxy.getDbSource());
- dbr.setVersion(null);
+ // BH 2019.01.25 dbr is never used.
+// DBRefEntry dbr = new DBRefEntry();
+// dbr.setSource(proxy.getDbSource());
+// dbr.setVersion(null);
String accId = proxy.getAccessionIdFromQuery(q);
- dbr.setAccessionId(accId);
+// dbr.setAccessionId(accId);
boolean rfound = false;
- for (int r = 0; r < rs.length; r++)
+ for (int r = 0, nr = rs.length; r < nr; r++)
{
if (rs[r] != null)
{
}
}
- if (seq.getDBRefs() != null && seq.getDBRefs().length != 0)
+ List<DBRefEntry> refs = seq.getDBRefs();
+ if (refs != null && refs.size() != 0)
{
- for (DBRefEntry dbRef : seq.getDBRefs())
+ for (int ib = 0, nb = refs.size(); ib < nb; ib++)
{
+ DBRefEntry dbRef = refs.get(ib);
if (isValidSeqName(getDBRefId(dbRef))
&& queryBuilder.length() < MAX_QLENGTH)
{
if (sq != null)
{
// search dbrefs, features and annotation
- DBRefEntry[] refs = jalview.util.DBRefUtils
+ List<DBRefEntry> refs = jalview.util.DBRefUtils
.selectRefs(sq.getDBRefs(), new String[]
{ labelClass.toUpperCase() });
if (refs != null)
{
- for (int i = 0; i < refs.length; i++)
+ for (int i = 0, ni = refs.size(); i < ni; i++)
{
if (newname == null)
{
- newname = new String(refs[i].getAccessionId());
+ newname = new String(refs.get(i).getAccessionId());
}
else
{
- newname = newname + "; " + refs[i].getAccessionId();
+ newname += "; " + refs.get(i).getAccessionId();
}
}
}
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JmolParser;
import jalview.structure.StructureImportSettings;
+import jalview.util.Platform;
import java.io.File;
import java.io.IOException;
{
protocol = DataSourceType.URL;
}
- else if (jalview.bin.Jalview.isJS())
+ else if (Platform.isJS())
{
protocol = DataSourceType.RELATIVE_URL;
}
if (hiddenSeqs != null && !hiddenSeqs.isEmpty())
{
String[] seqRefs = hiddenSeqs.split(";");
- for (String seqRef : seqRefs)
+ for (int i = seqRefs.length; --i >= 0;)
{
- hiddenSeqRefs.add(seqRef);
+ hiddenSeqRefs.add(seqRefs[i]);
}
}
}
{
hiddenColumns = new HiddenColumns();
String[] rangeStrings = hiddenCols.split(";");
- for (String rangeString : rangeStrings)
+ for (int i = rangeStrings.length; --i >= 0;)
{
- String[] range = rangeString.split("-");
+ String[] range = rangeStrings[i].split("-");
hiddenColumns.hideColumns(Integer.valueOf(range[0]),
Integer.valueOf(range[1]));
}
if (jsonSeqFeatures != null)
{
displayedFeatures = new FeaturesDisplayed();
- for (Iterator<Object> seqFeatureItr = jsonSeqFeatures
- .iterator(); seqFeatureItr.hasNext();)
+ for (Object o : jsonSeqFeatures)
{
- Map<String, Object> jsonFeature = (Map<String, Object>) seqFeatureItr.next();
+ Map<String, Object> jsonFeature = (Map<String, Object>) o;
Long begin = (Long) jsonFeature.get("xStart");
Long end = (Long) jsonFeature.get("xEnd");
String type = (String) jsonFeature.get("type");
package jalview.io;
import jalview.bin.Cache;
-import jalview.bin.Jalview;
import jalview.gui.JvOptionPane;
import jalview.util.MessageManager;
import jalview.util.Platform;
{
int value = super.showOpenDialog(this);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
/*
* code here is not run in JalviewJS, instead
*/
package jalview.io;
+import jalview.datamodel.DBRefEntry;
import jalview.datamodel.SequenceI;
+import java.util.List;
+
public class ModellerDescription
{
/**
if (seq.getDatasetSequence() != null
&& seq.getDatasetSequence().getDBRefs() != null)
{
- jalview.datamodel.DBRefEntry[] dbr = seq.getDatasetSequence()
- .getDBRefs();
- int i, j;
- for (i = 0, j = dbr.length; i < j; i++)
+ List<DBRefEntry> dbr = seq.getDatasetSequence().getDBRefs();
+ for (int i = 0, ni = dbr.size(); i < ni; i++)
{
- if (dbr[i] != null)
+ DBRefEntry dbri = dbr.get(i);
+ if (dbri != null)
{
// JBPNote PDB dbRefEntry needs properties to propagate onto
// ModellerField
// JBPNote Need to get info from the user about whether the sequence
// is the one being modelled, or if it is a template.
- if (dbr[i].getSource()
+ if (dbri.getSource()
.equals(jalview.datamodel.DBRefSource.PDB))
{
- fields.put(Fields[LOCALID], dbr[i].getAccessionId());
+ fields.put(Fields[LOCALID], dbri.getAccessionId());
t = 2;
break;
}
protected int appendDbRefs(final StringBuilder sb, SequenceI ds,
boolean summary)
{
- DBRefEntry[] dbrefs = ds.getDBRefs();
+ List<DBRefEntry> dbrefs = ds.getDBRefs();
if (dbrefs == null)
{
return 0;
}
// note this sorts the refs held on the sequence!
- Arrays.sort(dbrefs, comparator);
+ dbrefs.sort(comparator);
boolean ellipsis = false;
String source = null;
String lastSource = null;
{
private static final String ANNOTATION = "annotation";
- private static final Regex OPEN_PAREN = new Regex("(<|\\[)", "(");
-
- private static final Regex CLOSE_PAREN = new Regex("(>|\\])", ")");
+// private static final Regex OPEN_PAREN = new Regex("(<|\\[)", "(");
+//
+// private static final Regex CLOSE_PAREN = new Regex("(>|\\])", ")");
public static final Regex DETECT_BRACKETS = new Regex(
"(<|>|\\[|\\]|\\(|\\)|\\{|\\})");
Regex openparen = new Regex("(<|\\[)", "(");
Regex closeparen = new Regex("(>|\\])", ")");
- // Detect if file is RNA by looking for bracket types
- Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");
+// // Detect if file is RNA by looking for bracket types
+// Regex detectbrackets = new Regex("(<|>|\\[|\\]|\\(|\\))");
rend.optimize();
p.optimize();
// End of the alignment, pass stuff back
this.noSeqs = seqs.size();
- String seqdb, dbsource = null;
+ String dbsource = null;
Regex pf = new Regex("PF[0-9]{5}(.*)"); // Finds AC for Pfam
Regex rf = new Regex("RF[0-9]{5}(.*)"); // Finds AC for Rfam
if (getAlignmentProperty("AC") != null)
int max = 0;
int maxid = 0;
int in = 0;
- Hashtable dataRef = null;
- while ((in < s.length) && (s[in] != null))
+ int slen = s.length;
+ SequenceI seq;
+ Hashtable<String, String> dataRef = null;
+ while ((in < slen) && ((seq = s[in]) != null))
{
- String tmp = printId(s[in], jvSuffix);
- max = Math.max(max, s[in].getLength());
+ String tmp = printId(seq, jvSuffix);
+ max = Math.max(max, seq.getLength());
if (tmp.length() > maxid)
{
maxid = tmp.length();
}
- if (s[in].getDBRefs() != null)
+ List<DBRefEntry> seqrefs = seq.getDBRefs();
+ int ndb;
+ if (seqrefs != null && (ndb = seqrefs.size()) > 0)
{
- for (int idb = 0; idb < s[in].getDBRefs().length; idb++)
+ if (dataRef == null)
+ {
+ dataRef = new Hashtable<>();
+ }
+ for (int idb = 0; idb < ndb; idb++)
{
- if (dataRef == null)
- {
- dataRef = new Hashtable();
- }
- String datAs1 = s[in].getDBRefs()[idb].getSource().toString()
+ DBRefEntry ref = seqrefs.get(idb);
+ String datAs1 = ref.getSource().toString()
+ " ; "
- + s[in].getDBRefs()[idb].getAccessionId().toString();
+ + ref.getAccessionId().toString();
dataRef.put(tmp, datAs1);
}
}
// output database accessions
if (dataRef != null)
{
- Enumeration en = dataRef.keys();
+ Enumeration<String> en = dataRef.keys();
while (en.hasMoreElements())
{
Object idd = en.nextElement();
}
// output annotations
- while (i < s.length && s[i] != null)
+ while (i < slen && (seq = s[i]) != null)
{
- AlignmentAnnotation[] alAnot = s[i].getAnnotation();
+ AlignmentAnnotation[] alAnot = seq.getAnnotation();
if (alAnot != null)
{
Annotation[] ann;
- for (int j = 0; j < alAnot.length; j++)
+ for (int j = 0, nj = alAnot.length; j < nj; j++)
{
String key = type2id(alAnot[j].label);
// out.append("#=GR ");
out.append(new Format("%-" + maxid + "s").form(
- "#=GR " + printId(s[i], jvSuffix) + " " + key + " "));
+ "#=GR " + printId(seq, jvSuffix) + " " + key + " "));
ann = alAnot[j].annotations;
- String seq = "";
- for (int k = 0; k < ann.length; k++)
+ String sseq = "";
+ for (int k = 0, nk = ann.length; k < nk; k++)
{
- seq += outputCharacter(key, k, isrna, ann, s[i]);
+ sseq += outputCharacter(key, k, isrna, ann, seq);
}
- out.append(seq);
+ out.append(sseq);
out.append(newline);
}
}
out.append(new Format("%-" + maxid + "s")
- .form(printId(s[i], jvSuffix) + " "));
- out.append(s[i].getSequenceAsString());
+ .form(printId(seq, jvSuffix) + " "));
+ out.append(seq.getSequenceAsString());
out.append(newline);
i++;
}
// alignment annotation
AlignmentAnnotation aa;
- if (al.getAlignmentAnnotation() != null)
+ AlignmentAnnotation[] an = al.getAlignmentAnnotation();
+ if (an != null)
{
- for (int ia = 0; ia < al.getAlignmentAnnotation().length; ia++)
+ for (int ia = 0, na = an.length; ia < na; ia++)
{
- aa = al.getAlignmentAnnotation()[ia];
+ aa = an[ia];
if (aa.autoCalculated || !aa.visible || aa.sequenceRef != null)
{
continue;
}
- String seq = "";
+ String sseq = "";
String label;
String key = "";
if (aa.label.equals("seq"))
out.append(
new Format("%-" + maxid + "s").form("#=GC " + label + " "));
boolean isrna = aa.isValidStruc();
- for (int j = 0; j < aa.annotations.length; j++)
+ for (int j = 0, nj = aa.annotations.length; j < nj; j++)
{
- seq += outputCharacter(key, j, isrna, aa.annotations, null);
+ sseq += outputCharacter(key, j, isrna, aa.annotations, null);
}
- out.append(seq);
+ out.append(sseq);
out.append(newline);
}
}
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.StringTokenizer;
import java.util.Vector;
}
}
- DBRefEntry[] entries = oldseq.getDBRefs();
- if (entries != null)
+ List<DBRefEntry> entries = oldseq.getDBRefs();
+ // BH 2019.01.25 check for 0-length was missing here
+ if (entries != null && entries.size() > 0)
{
oldseq.addDBRef(new jalview.datamodel.DBRefEntry(
jalview.datamodel.DBRefSource.UNIPROT, "0",
- entries[0].getAccessionId()));
+ entries.get(0).getAccessionId()));
}
}
}
package jalview.io.cache;
import jalview.bin.Cache;
-import jalview.bin.Jalview;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public JvCacheableInputBox(String newCacheKey)
{
super();
- if (Jalview.isJS())
+ if (Platform.isJS())
{
textField = new JTextField();
return;
*/
public void updateCache()
{
- if (Jalview.isJS())
+ if (Platform.isJS())
{
return;
}
*/
public void persistCache()
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
appCache.persistCache(cacheKey);
}
*/
public String getUserInput()
{
- if (Jalview.isJS())
+ if (Platform.isJS())
{
return textField.getText().trim();
}
public JComponent getComponent()
{
- return Jalview.isJS() ? textField : comboBox;
+ return Platform.isJS() ? textField : comboBox;
}
public void addActionListener(ActionListener actionListener)
{
- if (Jalview.isJS())
+ if (Platform.isJS())
{
textField.addActionListener(actionListener);
}
public void addDocumentListener(DocumentListener listener)
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
((JTextComponent) comboBox.getEditor().getEditorComponent())
.getDocument().addDocumentListener(listener);
public void addFocusListener(FocusListener focusListener)
{
- if (Jalview.isJS())
+ if (Platform.isJS())
{
textField.addFocusListener(focusListener);
}
public void addKeyListener(KeyListener kl)
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
comboBox.getEditor().getEditorComponent().addKeyListener(kl);
}
public void setEditable(boolean b)
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
comboBox.setEditable(b);
}
public void setPrototypeDisplayValue(String string)
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
comboBox.setPrototypeDisplayValue(string);
}
public void setSelectedItem(String userInput)
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
comboBox.setSelectedItem(userInput);
}
public boolean isPopupVisible()
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
return comboBox.isPopupVisible();
}
public void addCaretListener(CaretListener caretListener)
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
((JTextComponent) comboBox.getEditor().getEditorComponent())
.addCaretListener(caretListener);
public void addItem(String item)
{
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
comboBox.addItem(item);
}
if (sq.getDatasetSequence() == null && sq.getDBRefs() != null)
{
// only sync database references for dataset sequences
- DBRefEntry[] entries = sq.getDBRefs();
+ List<DBRefEntry> entries = sq.getDBRefs();
// jalview.datamodel.DBRefEntry dbentry;
- for (int db = 0; db < entries.length; db++)
+ for (int db = 0, dn = entries.size(); db < dn; db++)
{
modifiedthedoc |= new jalview.io.vamsas.Dbref(datastore,
// dbentry =
- entries[db], sq, (Sequence) vobj, dataset).docWasUpdated();
+ entries.get(db), sq, (Sequence) vobj, dataset).docWasUpdated();
}
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
import jalview.datamodel.Mapping;
import jalview.datamodel.SequenceI;
import jalview.gui.Desktop;
import jalview.io.VamsasAppDatastore;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Vector;
import uk.ac.vamsas.objects.core.AlignmentSequence;
jalview.bin.Cache.log.debug("Matching conjugate refs for "
+ from.getName() + " and " + to.getName());
}
- jalview.datamodel.DBRefEntry[] fdb = from.getDBRefs();
- jalview.datamodel.DBRefEntry[] tdb = new jalview.datamodel.DBRefEntry[to
- .getDBRefs().length];
- int tdblen = to.getDBRefs().length;
- System.arraycopy(to.getDBRefs(), 0, tdb, 0, tdblen);
+ List<DBRefEntry> fdb = from.getDBRefs();
+ List<DBRefEntry> tdb = new ArrayList<DBRefEntry>(to.getDBRefs());
+ int tdblen = to.getDBRefs().size();
+//
+//
+// YOWSER
+//
+// 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++)
+ for (int f = 0, fn = fdb.size(); f < fn; f++)
{
- jalview.datamodel.DBRefEntry fe = fdb[f];
+ jalview.datamodel.DBRefEntry fe = fdb.get(f);
jalview.datamodel.Mapping fmp = fe.getMap();
- boolean fmpnnl = fmp != null;
+ boolean fmpnnl = (fmp != null);
// if (fmpnnl && fmp.getTo()!=null)
// {
// jalview.bin.Cache.log.debug("Not overwriting existing To reference in
: false;
for (int t = 0; t < tdblen; t++)
{
- jalview.datamodel.DBRefEntry te = tdb[t];
+ jalview.datamodel.DBRefEntry te = tdb.get(t);
if (te != null)
{
if (fe.getSource().equals(te.getSource())
*/
protected void transferAddedFeatures(SequenceI seq)
{
- DBRefEntry[] dbrefs = seq.getDBRefs();
+ List<DBRefEntry> dbrefs = seq.getDBRefs();
if (dbrefs == null)
{
return;
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.api.SplitContainerI;
import jalview.bin.Cache;
-import jalview.bin.Jalview;
import jalview.gui.JvSwingUtils;
import jalview.gui.Preferences;
import jalview.io.FileFormats;
alignFrameMenuBar.add(formatMenu);
alignFrameMenuBar.add(colourMenu);
alignFrameMenuBar.add(calculateMenu);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
alignFrameMenuBar.add(webService);
}
fileMenu.add(exportAnnotations);
fileMenu.add(loadTreeMenuItem);
fileMenu.add(associatedData);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
fileMenu.add(loadVcf);
}
calculateMenu.addSeparator();
calculateMenu.add(expandAlignment);
calculateMenu.add(extractScores);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
calculateMenu.addSeparator();
calculateMenu.add(runGroovy);
webServiceNoServices = new JMenuItem(
MessageManager.getString("label.no_services"));
webService.add(webServiceNoServices);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
exportImageMenu.add(htmlMenuItem);
}
exportImageMenu.add(epsFile);
exportImageMenu.add(createPNG);
exportImageMenu.add(createBioJS);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
exportImageMenu.add(createSVG);
}
package jalview.jbgui;
import jalview.api.AlignmentViewPanel;
-import jalview.bin.Jalview;
import jalview.io.FileFormatException;
import jalview.util.MessageManager;
import jalview.util.Platform;
FileMenu.addSeparator();
FileMenu.add(saveAsJaxb);
FileMenu.add(loadAsJaxb);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
FileMenu.add(saveState);
FileMenu.add(loadState);
VamsasMenu.add(vamsasSave);
VamsasMenu.add(vamsasStop);
toolsMenu.add(preferences);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
toolsMenu.add(showMemusage);
toolsMenu.add(showConsole);
}
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
toolsMenu.add(showNews);
toolsMenu.add(garbageCollect);
*/
package jalview.jbgui;
-import jalview.bin.Jalview;
import jalview.fts.core.FTSDataColumnPreferences;
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
import jalview.fts.service.pdb.PDBFTSRestClient;
import jalview.gui.JvSwingUtils;
import jalview.gui.StructureViewer.ViewerType;
import jalview.util.MessageManager;
+import jalview.util.Platform;
import java.awt.BorderLayout;
import java.awt.Color;
/*
* See WsPreferences for the real work of configuring this tab.
*/
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
wsTab.setLayout(new BorderLayout());
tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
outputTab.add(userIdWidth);
outputTab.add(userIdWidthlabel);
outputTab.add(modellerOutput);
- if (!Jalview.isJS())
+ if (!Platform.isJS())
{
/*
* JalviewJS doesn't support Lineart option or SVG output
/*
* hide Chimera options in JalviewJS
*/
- if (Jalview.isJS())
+ if (Platform.isJS())
{
pathLabel.setVisible(false);
chimeraPath.setVisible(false);
visualTab.add(fontSizeCB);
visualTab.add(fontStyleCB);
- if (Jalview.isJS())
+ if (Platform.isJS())
{
startupCheckbox.setVisible(false);
startupFileTextfield.setVisible(false);
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.DBRefEntry;
import jalview.datamodel.GraphLine;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.RnaViewerModel;
vamsasSeq.setName(jds.getName());
vamsasSeq.setSequence(jds.getSequenceAsString());
vamsasSeq.setDescription(jds.getDescription());
- jalview.datamodel.DBRefEntry[] dbrefs = null;
+ List<DBRefEntry> dbrefs = null;
if (jds.getDatasetSequence() != null)
{
vamsasSeq.setDsseqid(seqHash(jds.getDatasetSequence()));
}
if (dbrefs != null)
{
- for (int d = 0; d < dbrefs.length; d++)
+ for (int d = 0, nd = dbrefs.size(); d < nd; d++)
{
DBRef dbref = new DBRef();
- dbref.setSource(dbrefs[d].getSource());
- dbref.setVersion(dbrefs[d].getVersion());
- dbref.setAccessionId(dbrefs[d].getAccessionId());
- if (dbrefs[d].hasMap())
+ DBRefEntry ref = dbrefs.get(d);
+ dbref.setSource(ref.getSource());
+ dbref.setVersion(ref.getVersion());
+ dbref.setAccessionId(ref.getAccessionId());
+ if (ref.hasMap())
{
- Mapping mp = createVamsasMapping(dbrefs[d].getMap(), parentseq,
+ Mapping mp = createVamsasMapping(ref.getMap(), parentseq,
jds, recurse);
dbref.setMapping(mp);
}
import jalview.analysis.Rna;
import jalview.analysis.StructureFrequency;
import jalview.api.AlignViewportI;
-import jalview.bin.Jalview;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
// int hght = (int) (ht + (newAsc - newDec);
// - lm.getBaselineOffsets()[lm.getBaselineIndex()]));
- if (Jalview.isJS())
+ if (Platform.isJS())
{
/*
* SwingJS does not implement font.deriveFont()
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
+import jalview.datamodel.Mapping;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.BitSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import com.stevesoft.pat.Regex;
*/
public class DBRefUtils
{
+
+ public final static int DB_SOURCE = 1;
+ public final static int DB_VERSION = 2;
+ public final static int DB_ID = 4;
+ public final static int DB_MAP = 8;
+
+
+ public final static int SEARCH_MODE_NO_MAP_NO_VERSION = DB_SOURCE | DB_ID;
+ public final static int SEARCH_MODE_FULL = DB_SOURCE | DB_VERSION | DB_ID | DB_MAP;
+
/*
* lookup from lower-case form of a name to its canonical (standardised) form
*/
canonicalSourceNameLookup.put("ensembl-gn", DBRefSource.ENSEMBL);
// Make sure we have lowercase entries for all canonical string lookups
- Set<String> keys = canonicalSourceNameLookup.keySet();
- for (String k : keys)
- {
- canonicalSourceNameLookup.put(k.toLowerCase(),
- canonicalSourceNameLookup.get(k));
- }
+// BH 2019.01.25 unnecessary -- they are all lower case already
+ //Set<String> keys = canonicalSourceNameLookup.keySet();
+// for (String k : keys)
+// {
+// canonicalSourceNameLookup.put(k.toLowerCase(),
+// canonicalSourceNameLookup.get(k));
+// }
dasCoordinateSystemsLookup.put("pdbresnum", DBRefSource.PDB);
dasCoordinateSystemsLookup.put("uniprot", DBRefSource.UNIPROT);
* array of sources to select
* @return
*/
- public static DBRefEntry[] selectRefs(DBRefEntry[] dbrefs,
+ public static List<DBRefEntry> selectRefs(List<DBRefEntry> dbrefs,
String[] sources)
{
if (dbrefs == null || sources == null)
{
return dbrefs;
}
+
+ // BH TODO
HashSet<String> srcs = new HashSet<String>();
for (String src : sources)
{
srcs.add(src.toUpperCase());
}
+ int nrefs = dbrefs.size();
List<DBRefEntry> res = new ArrayList<DBRefEntry>();
- for (DBRefEntry dbr : dbrefs)
+ for (int ib = 0; ib < nrefs; ib++)
{
+ DBRefEntry dbr = dbrefs.get(ib);
String source = getCanonicalName(dbr.getSource());
if (srcs.contains(source.toUpperCase()))
{
if (res.size() > 0)
{
- DBRefEntry[] reply = new DBRefEntry[res.size()];
- return res.toArray(reply);
+ //List<DBRefEntry> reply = new DBRefEntry[res.size()];
+ return res;//.toArray(reply);
}
return null;
}
+ private static boolean selectRefsBS(List<DBRefEntry> dbrefs, String sourceKeys, BitSet bsSelect) {
+ if (dbrefs == null || sourceKeys == null)
+ {
+ return false;
+ }
+ for (int i = 0, n = dbrefs.size(); i < n; i++)
+ {
+ DBRefEntry dbr = dbrefs.get(i);
+ String sourceKey = dbr.getSourceKey();
+ if (sourceKeys.indexOf(sourceKey) < 0) {
+ bsSelect.clear(i);
+ }
+ }
+ return !bsSelect.isEmpty();
+ }
+
+
/**
* isDasCoordinateSystem
*
* Set of references to search
* @param entry
* pattern to match
+ * @param mode SEARCH_MODE_FULL for all; SEARCH_MODE_NO_MAP_NO_VERSION optional
* @return
*/
- public static List<DBRefEntry> searchRefs(DBRefEntry[] ref,
- DBRefEntry entry)
+ public static List<DBRefEntry> searchRefs(List<DBRefEntry> ref,
+ DBRefEntry entry, int mode)
{
return searchRefs(ref, entry,
- matchDbAndIdAndEitherMapOrEquivalentMapList);
+ matchDbAndIdAndEitherMapOrEquivalentMapList, mode);
}
/**
* accession id to match
* @return
*/
- public static List<DBRefEntry> searchRefs(DBRefEntry[] refs, String accId)
+ public static List<DBRefEntry> searchRefs(List<DBRefEntry> refs, String accId)
{
- return searchRefs(refs, new DBRefEntry("", "", accId), matchId);
+ List<DBRefEntry> rfs = new ArrayList<DBRefEntry>();
+ if (refs == null || accId == null)
+ {
+ return rfs;
+ }
+ for (int i = 0, n = refs.size(); i < n; i++)
+ {
+ DBRefEntry e = refs.get(i);
+ if (accId.equals(e.getAccessionId()))
+ {
+ rfs.add(e);
+ }
+ }
+ return rfs;
+// return searchRefs(refs, new DBRefEntry("", "", accId), matchId, SEARCH_MODE_FULL);
}
+
/**
* Returns a (possibly empty) list of those references that match the given
* entry, according to the given comparator.
* @param entry
* an entry to compare against
* @param comparator
+ * @param mode SEARCH_MODE_FULL for all; SEARCH_MODE_NO_MAP_NO_VERSION optional
* @return
*/
- static List<DBRefEntry> searchRefs(DBRefEntry[] refs, DBRefEntry entry,
- DbRefComp comparator)
+ static List<DBRefEntry> searchRefs(List<DBRefEntry> refs, DBRefEntry entry,
+ DbRefComp comparator, int mode)
{
List<DBRefEntry> rfs = new ArrayList<DBRefEntry>();
if (refs == null || entry == null)
{
return rfs;
}
- for (int i = 0; i < refs.length; i++)
+ for (int i = 0, n = refs.size(); i < n; i++)
{
- if (comparator.matches(entry, refs[i]))
+ DBRefEntry e = refs.get(i);
+ if (comparator.matches(entry, e, SEARCH_MODE_FULL))
{
- rfs.add(refs[i]);
+ rfs.add(e);
}
}
return rfs;
interface DbRefComp
{
- public boolean matches(DBRefEntry refa, DBRefEntry refb);
- }
+ default public boolean matches(DBRefEntry refa, DBRefEntry refb) {
+ return matches(refa, refb, SEARCH_MODE_FULL);
+ };
+
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode);
+}
/**
* match on all non-null fields in refa
// TODO unused - remove?
public static DbRefComp matchNonNullonA = new DbRefComp()
{
- @Override
- public boolean matches(DBRefEntry refa, DBRefEntry refb)
+ @Override
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode)
{
- if (refa.getSource() == null
+ if ((mode & DB_SOURCE) != 0 && refa.getSource() == null
|| DBRefUtils.getCanonicalName(refb.getSource()).equals(
DBRefUtils.getCanonicalName(refa.getSource())))
{
- if (refa.getVersion() == null
+ if ((mode & DB_VERSION) != 0 && refa.getVersion() == null
|| refb.getVersion().equals(refa.getVersion()))
{
- if (refa.getAccessionId() == null
+ if ((mode & DB_ID) != 0 && refa.getAccessionId() == null
|| refb.getAccessionId().equals(refa.getAccessionId()))
{
- if (refa.getMap() == null || (refb.getMap() != null
+ if ((mode & DB_MAP) != 0 && refa.getMap() == null || (refb.getMap() != null
&& refb.getMap().equals(refa.getMap())))
{
return true;
public static DbRefComp matchEitherNonNull = new DbRefComp()
{
@Override
- public boolean matches(DBRefEntry refa, DBRefEntry refb)
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode)
{
if (nullOrEqualSource(refa.getSource(), refb.getSource())
&& nullOrEqual(refa.getVersion(), refb.getVersion())
}
return false;
}
+
};
/**
public static DbRefComp matchDbAndIdAndEitherMap = new DbRefComp()
{
@Override
- public boolean matches(DBRefEntry refa, DBRefEntry refb)
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode)
{
if (refa.getSource() != null && refb.getSource() != null
&& DBRefUtils.getCanonicalName(refb.getSource()).equals(
public static DbRefComp matchDbAndIdAndComplementaryMapList = new DbRefComp()
{
@Override
- public boolean matches(DBRefEntry refa, DBRefEntry refb)
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode)
{
if (refa.getSource() != null && refb.getSource() != null
&& DBRefUtils.getCanonicalName(refb.getSource()).equals(
public static DbRefComp matchDbAndIdAndEquivalentMapList = new DbRefComp()
{
@Override
- public boolean matches(DBRefEntry refa, DBRefEntry refb)
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode)
{
if (refa.getSource() != null && refb.getSource() != null
&& DBRefUtils.getCanonicalName(refb.getSource()).equals(
public static DbRefComp matchDbAndIdAndEitherMapOrEquivalentMapList = new DbRefComp()
{
@Override
- public boolean matches(DBRefEntry refa, DBRefEntry refb)
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode)
{
if (refa.getSource() != null && refb.getSource() != null
&& DBRefUtils.getCanonicalName(refb.getSource()).equals(
public static DbRefComp matchId = new DbRefComp()
{
@Override
- public boolean matches(DBRefEntry refa, DBRefEntry refb)
+ public boolean matches(DBRefEntry refa, DBRefEntry refb, int mode)
{
if (refa.getAccessionId() != null && refb.getAccessionId() != null
&& refb.getAccessionId().equals(refa.getAccessionId()))
* a set of references to select from
* @return
*/
- public static DBRefEntry[] selectDbRefs(boolean selectDna,
- DBRefEntry[] refs)
+ public static List<DBRefEntry> selectDbRefs(boolean selectDna,
+ List<DBRefEntry> refs)
{
return selectRefs(refs,
selectDna ? DBRefSource.DNACODINGDBS : DBRefSource.PROTEINDBS);
* @param source
* @return
*/
- public static List<DBRefEntry> searchRefsForSource(DBRefEntry[] dbRefs,
+ public static List<DBRefEntry> searchRefsForSource(List<DBRefEntry> dbRefs,
String source)
{
List<DBRefEntry> matches = new ArrayList<DBRefEntry>();
// nothing to do
return;
}
- List<DBRefEntry> selfs = new ArrayList<DBRefEntry>();
- {
- DBRefEntry[] selfArray = selectDbRefs(!sequence.isProtein(),
- sequence.getDBRefs());
- if (selfArray == null || selfArray.length == 0)
- {
- // nothing to do
- return;
- }
- selfs.addAll(Arrays.asList(selfArray));
- }
+ int sstart = sequence.getStart();
+ int send = sequence.getEnd();
+ boolean isProtein = sequence.isProtein();
+ BitSet bsSelect = new BitSet();
+
+// List<DBRefEntry> selfs = new ArrayList<DBRefEntry>();
+// {
+
+// List<DBRefEntry> selddfs = selectDbRefs(!isprot, sequence.getDBRefs());
+// if (selfs == null || selfs.size() == 0)
+// {
+// // nothing to do
+// return;
+// }
+
+ List<DBRefEntry> dbrefs = sequence.getDBRefs();
+ bsSelect.set(0, dbrefs.size());
+
+ if (!selectRefsBS(dbrefs, isProtein ? DBRefSource.PROTEINDBSKEYS : DBRefSource.DNACODINGDBSKEYS, bsSelect))
+ return;
+
+// selfs.addAll(selfArray);
+// }
// filter non-primary refs
- for (DBRefEntry p : pr)
+ for (int ip = pr.size(); --ip >= 0;)
{
- while (selfs.contains(p))
- {
- selfs.remove(p);
+ DBRefEntry p = pr.get(ip);
+ for (int i = bsSelect.nextSetBit(0); i >= 0; i = bsSelect.nextSetBit(i + 1)) {
+ if (dbrefs.get(i) == p)
+ bsSelect.clear(i);
}
+// while (selfs.contains(p))
+// {
+// selfs.remove(p);
+// }
}
- List<DBRefEntry> toPromote = new ArrayList<DBRefEntry>();
+// List<DBRefEntry> toPromote = new ArrayList<DBRefEntry>();
- for (DBRefEntry p : pr)
+
+
+ for (int ip = pr.size(), keys = 0; --ip >= 0 && keys != DBRefSource.ALL_MASKS;)
{
- List<String> promType = new ArrayList<String>();
- if (sequence.isProtein())
+ DBRefEntry p = pr.get(ip);
+ if (isProtein)
{
switch (getCanonicalName(p.getSource()))
{
case DBRefSource.UNIPROT:
- // case DBRefSource.UNIPROTKB:
- // case DBRefSource.UP_NAME:
- // search for and promote ensembl
- promType.add(DBRefSource.ENSEMBL);
+ keys |= DBRefSource.UNIPROT_MASK;
break;
case DBRefSource.ENSEMBL:
- // search for and promote Uniprot
- promType.add(DBRefSource.UNIPROT);
+ keys |= DBRefSource.ENSEMBL_MASK;
break;
}
}
else
{
- // TODO: promote transcript refs
+ // TODO: promote transcript refs ??
}
-
- // collate candidates and promote them
- DBRefEntry[] candidates = selectRefs(selfs.toArray(new DBRefEntry[0]),
- promType.toArray(new String[0]));
- if (candidates != null)
+ if (keys == 0 || !selectRefsBS(dbrefs, DBRefSource.PROMTYPES[keys], bsSelect))
+ return;
+// if (candidates != null)
{
- for (DBRefEntry cand : candidates)
+ for (int ic = bsSelect.nextSetBit(0); ic >= 0; ic = bsSelect.nextSetBit(ic + 1))
+// for (int ic = 0, n = candidates.size(); ic < n; ic++)
{
+ DBRefEntry cand = dbrefs.get(ic);//candidates.get(ic);
if (cand.hasMap())
{
- if (cand.getMap().getTo() != null
- && cand.getMap().getTo() != sequence)
+ Mapping map = cand.getMap();
+ SequenceI cto = map.getTo();
+ if (cto != null
+ && cto != sequence)
{
// can't promote refs with mappings to other sequences
continue;
}
- if (cand.getMap().getMap().getFromLowest() != sequence
- .getStart()
- && cand.getMap().getMap().getFromHighest() != sequence
- .getEnd())
+ MapList mlist = map.getMap();
+ if (mlist.getFromLowest() != sstart
+ && mlist.getFromHighest() != send)
{
// can't promote refs with mappings from a region of this sequence
// - eg CDS
}
// and promote
cand.setVersion(p.getVersion() + " (promoted)");
- selfs.remove(cand);
- toPromote.add(cand);
+ bsSelect.clear(ic);
+ //selfs.remove(cand);
+// toPromote.add(cand);
if (!cand.isPrimaryCandidate())
{
System.out.println(
if (usesDBAccession()) // link is ID
{
// collect matching db-refs
- DBRefEntry[] dbr = DBRefUtils.selectRefs(seq.getDBRefs(),
+ List<DBRefEntry> dbr = DBRefUtils.selectRefs(seq.getDBRefs(),
new String[]
{ target });
// if there are any dbrefs which match up with the link
if (dbr != null)
{
- for (int r = 0; r < dbr.length; r++)
+ for (int r = 0, nd = dbr.size(); r < nd; r++)
{
// create Bare ID link for this URL
- createBareURLLink(dbr[r].getAccessionId(), true, linkset);
+ createBareURLLink(dbr.get(r).getAccessionId(), true, linkset);
}
}
}
&& (i < 50); seqIndex++, i++)
{
SequenceI sequence = dataset[seqIndex];
- DBRefEntry[] uprefs = DBRefUtils
+ List<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)
+ if (uprefs != null && uprefs.size() > 0)
{
- for (int j = 0; j < uprefs.length; j++)
+ for (int j = 0, n = uprefs.size(); j < n; j++)
{
- addSeqId(sequence, uprefs[j].getAccessionId());
+ DBRefEntry upref = uprefs.get(j);
+ addSeqId(sequence, upref.getAccessionId());
queries.addElement(
- uprefs[j].getAccessionId().toUpperCase());
+ upref.getAccessionId().toUpperCase());
}
}
else
// taking into account all accessionIds and names in the file
Vector<SequenceI> sequenceMatches = new Vector<>();
// look for corresponding accession ids
- DBRefEntry[] entryRefs = DBRefUtils
+ List<DBRefEntry> entryRefs = DBRefUtils
.selectRefs(retrievedSeq.getDBRefs(), new String[]
{ dbSource });
if (entryRefs == null)
+ dbSource + " on " + retrievedSeq.getName());
continue;
}
- for (int j = 0; j < entryRefs.length; j++)
+ for (int j = 0, n = entryRefs.size(); j < n; j++)
{
- String accessionId = entryRefs[j].getAccessionId();
+ DBRefEntry ref = entryRefs.get(j);
+ String accessionId = ref.getAccessionId();
// match up on accessionId
if (seqRefs.containsKey(accessionId.toUpperCase()))
{
// could be useful to extend this so we try to find any 'significant'
// information in common between two sequence objects.
/*
- * DBRefEntry[] entryRefs =
+ * List<DBRefEntry> entryRefs =
* jalview.util.DBRefUtils.selectRefs(entry.getDBRef(), new String[] {
* dbSource }); for (int j = 0; j < entry.getName().size(); j++) { String
* name = entry.getName().elementAt(j).toString(); if
// TODO: test for legacy where uniprot or EMBL refs exist but no
// mappings are made (but content matches retrieved set)
boolean updateRefFrame = sequence.getDBRefs() == null
- || sequence.getDBRefs().length == 0;
+ || sequence.getDBRefs().size() == 0;
// TODO:
// verify sequence against the entry sequence
*/
private SequenceI[] recoverDbSequences(SequenceI[] sequencesArray)
{
- Vector<SequenceI> nseq = new Vector<>();
- for (int i = 0; sequencesArray != null
- && i < sequencesArray.length; i++)
+ int n;
+ if (sequencesArray == null || (n = sequencesArray.length) == 0)
+ return sequencesArray;
+ ArrayList<SequenceI> nseq = new ArrayList<>();
+ for (int i = 0;i < n; i++)
{
- nseq.addElement(sequencesArray[i]);
- DBRefEntry[] dbr = sequencesArray[i].getDBRefs();
+ nseq.add(sequencesArray[i]);
+ List<DBRefEntry> dbr = sequencesArray[i].getDBRefs();
Mapping map = null;
- for (int r = 0; (dbr != null) && r < dbr.length; r++)
+ if (dbr != null)
{
- if ((map = dbr[r].getMap()) != null)
+ for (int r = 0, rn = dbr.size(); r < rn; r++)
{
- if (map.getTo() != null && !nseq.contains(map.getTo()))
+ if ((map = dbr.get(r).getMap()) != null)
{
- nseq.addElement(map.getTo());
- }
+ if (map.getTo() != null && !nseq.contains(map.getTo()))
+ {
+ nseq.add(map.getTo());
+ }
+ }
}
}
}
+ // BH 2019.01.25 question here if this is the right logic. Return the original if nothing found?
if (nseq.size() > 0)
{
- sequencesArray = new SequenceI[nseq.size()];
- nseq.toArray(sequencesArray);
+ return nseq.toArray(new SequenceI[nseq.size()]);
}
return sequencesArray;
}
@Override
public List<WsParamSetI> getPresets()
{
- List<WsParamSetI> prefs = new ArrayList();
+ List<WsParamSetI> prefs = new ArrayList<>();
if (servicePresets == null)
{
servicePresets = new Hashtable<String, JabaPreset>();
for (int is = 0; is < seqs.length; is++)
{
rseqs.addElement(seqs[is]);
+ // BH 2015.01.25 check about version/accessid being null here
List<DBRefEntry> frefs = DBRefUtils.searchRefs(
seqs[is].getDBRefs(),
- new DBRefEntry(db, null, null));
+ new DBRefEntry(db, null, null), DBRefUtils.SEARCH_MODE_FULL);
for (DBRefEntry dbr : frefs)
{
queriesFound.add(dbr.getAccessionId());
package jalview.ws.utils;
+import jalview.util.Platform;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
public static void download(String urlstring, File tempFile) throws IOException
{
- if (/** @j2sNative 1?false: */true) {
+ // BH 2019.01.25 this said "...getFileAsBytes(..." which cannot work.
+ // maybe we cannot get here?
+ if (Platform.isJS()) {
+ /** @j2sNative
+ * tempFile._bytes = swingjs.JSUtil.getFileAsBytes$O(urlstring);
+ */
+ } else {
download(urlstring, tempFile.toString());
}
- // JavaScript only
-
- /** @j2sNative
- * tempFile._bytes = swingjs.JSUtil.getFileAsBytes(urlstring);
- */
}
}