public class Sequence extends ASequence implements SequenceI
{
- /**
- * 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>
- */
+ /**
+ * 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")
- public class DBModList<T> extends ArrayList<DBRefEntry> {
+ public class DBModList<T> extends ArrayList<DBRefEntry>
+ {
+
+ protected int getModCount()
+ {
+ return modCount;
+ }
- protected int getModCount() {
- return modCount;
- }
-
}
-SequenceI datasetSequence;
+ SequenceI datasetSequence;
private String name;
private int refModCount = 0;
private RNA rna;
-
+
/**
* This annotation is displayed below the alignment but the positions are tied
* to the residues of this sequence
{
setDatasetSequence(seq.getDatasetSequence());
}
-
+
/*
* only copy DBRefs and seqfeatures if we really are a dataset sequence
*/
{
if (sf.getType() == null)
{
- System.err.println("SequenceFeature type may not be null: "
- + sf.toString());
+ System.err.println(
+ "SequenceFeature type may not be null: " + sf.toString());
return false;
}
public char[] getSequence()
{
// return sequence;
- return sequence == null ? null : Arrays.copyOf(sequence,
- sequence.length);
+ return sequence == null ? null
+ : Arrays.copyOf(sequence, sequence.length);
}
/*
public void setGeneLoci(String speciesId, String assemblyId,
String chromosomeId, MapList map)
{
- addDBRef(new DBRefEntry(speciesId, assemblyId, DBRefEntry.CHROMOSOME
- + ":" + chromosomeId, new Mapping(map)));
+ addDBRef(new DBRefEntry(speciesId, assemblyId,
+ DBRefEntry.CHROMOSOME + ":" + chromosomeId, new Mapping(map)));
}
/**
@Override
public String getAssemblyId()
{
- // DEV NOTE: DBRefEntry is reused here to hold chromosomal locus of a gene sequence.
- // source=species, version=assemblyId, accession=chromosome, map = positions.
-
+ // DEV NOTE: DBRefEntry is reused here to hold chromosomal locus
+ // of a gene sequence.
+ // source=species, version=assemblyId, accession=chromosome, map =
+ // positions.
+
return ref.getVersion();
}
public String getChromosomeId()
{
// strip off "chromosome:" prefix to chrId
- return ref.getAccessionId().substring(
- DBRefEntry.CHROMOSOME.length() + 1);
+ return ref.getAccessionId()
+ .substring(DBRefEntry.CHROMOSOME.length() + 1);
}
@Override
{
return findPosition(column + 1, cursor);
}
-
+
// TODO recode this more naturally i.e. count residues only
// as they are found, not 'in anticipation'
{
ArrayList<int[]> map = new ArrayList<>();
int lastj = -1, j = 0;
- int pos = start;
+ // int pos = start;
int seqlen = sequence.length;
while ((j < seqlen))
{
{
BitSet map = new BitSet();
int lastj = -1, j = 0;
- int pos = start;
+ // int pos = start;
int seqlen = sequence.length;
while ((j < seqlen))
{
return dbrefs;
}
-
@Override
public void addDBRef(DBRefEntry entry)
{
if (dbrefs == null)
{
- dbrefs = new DBModList<DBRefEntry>();
+ dbrefs = new DBModList<>();
}
- for (int ib = 0, nb= dbrefs.size(); ib < nb; ib++)
+ for (int ib = 0, nb = dbrefs.size(); ib < nb; ib++)
{
if (dbrefs.get(ib).updateFrom(entry))
{
}
}
+ // /// 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;
-// /// 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);
}
private int _seqhash = 0;
-private List<DBRefEntry> primaryRefs;
+ private List<DBRefEntry> primaryRefs;
/**
* Answers false if the sequence is more than 85% nucleotide (ACGTU), else
List<SequenceFeature> sfs = entry.getSequenceFeatures();
for (SequenceFeature feature : sfs)
{
- SequenceFeature sf[] = (mp != null) ? mp.locateFeature(feature)
- : new SequenceFeature[] { new SequenceFeature(feature) };
+ SequenceFeature sf[] = (mp != null) ? mp.locateFeature(feature)
+ : new SequenceFeature[]
+ { new SequenceFeature(feature) };
if (sf != null)
{
for (int sfi = 0; sfi < sf.length; sfi++)
}
private List<DBRefEntry> tmpList;
-
+
@Override
public List<DBRefEntry> getPrimaryDBRefs()
{
synchronized (dbrefs)
{
if (refModCount == dbrefs.getModCount() && primaryRefs != null)
- return primaryRefs; // no changes
- refModCount = dbrefs.getModCount();
- List<DBRefEntry> primaries = (primaryRefs == null ? (primaryRefs = new ArrayList<>()) : primaryRefs);
+ {
+ return primaryRefs; // no changes
+ }
+ refModCount = dbrefs.getModCount();
+ List<DBRefEntry> primaries = (primaryRefs == null
+ ? (primaryRefs = new ArrayList<>())
+ : primaryRefs);
primaries.clear();
- if (tmpList == null) {
- tmpList = new ArrayList<>();
- tmpList.add(null); // for replacement
+ 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);
+ DBRefEntry ref = dbrefs.get(i);
if (!ref.isPrimaryCandidate())
{
continue;
}
}
// whilst it looks like it is a primary ref, we also sanity check type
- if (DBRefSource.PDB_CANONICAL_NAME.equals(ref.getCanonicalSourceName()))
+ if (DBRefSource.PDB_CANONICAL_NAME
+ .equals(ref.getCanonicalSourceName()))
{
// PDB dbrefs imply there should be a PDBEntry associated
// TODO: tighten PDB dbrefs
{
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;
- }
- }
+ }
+ 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);
}
-
- // version must be not null, as otherwise it will not be a candidate, above
+
+ // version must be not null, as otherwise it will not be a candidate,
+ // above
DBRefUtils.ensurePrimaries(this, primaries);
return primaries;
}