private AlignFrame frame;
private final AlignCalcManagerI2 calcMan;
private Map<String, SequenceI> seqNames;
+ /**
+ * indicates columns consisting of gaps only
+ */
boolean[] gapMap = new boolean[0];
int start, end;
boolean transferSequenceFeatures = false;
private WSJob job;
private List<AlignmentAnnotation> ourAnnots;
-
+
private int exceptionCount = MAX_RETRY;
private static final int MAX_RETRY = 5;
-
+
AnnotationServiceWorker(AnnotationOperation operation, WebServiceI service,
List<ArgumentI> args, AlignViewport viewport, AlignmentViewPanel alignPanel,
IProgressIndicator progressIndicator, AlignFrame frame, AlignCalcManagerI2 calcMan)
this.frame = frame;
this.calcMan = calcMan;
}
-
+
@Override
public String getCalcName()
{
{
if (!calcMan.isWorking(this) && job != null && !job.getStatus().isCompleted())
{
+ // is it correct to store annotations in a field and use them here?
updateResultAnnotation(ourAnnots);
}
}
{
return;
}
+ /* What "bySequence" means in this context and
+ * what is the SelectionGroup and why is it only relevant when
+ * not dealing with alignment analysis? */
var bySequence = !operation.isAlignmentAnalysis();
sequences = prepareInput(viewport.getAlignment(),
bySequence ? viewport.getSelectionGroup() : null);
service.getName()));
job = new WSJob(service.getProviderName(), service.getName(),
service.getHostName());
+ // Should this part be moved out of this class to one of the gui
+ // classes?
if (progressIndicator != null)
{
job.addPropertyChangeListener("status", new ProgressBarUpdater(progressIndicator));
private List<SequenceI> prepareInput(AlignmentI alignment,
AnnotatedCollectionI inputSeqs)
{
- if (alignment == null || alignment.getWidth() <= 0 ||
+ if (alignment == null || alignment.getWidth() <= 0 ||
alignment.getSequences() == null)
return null;
if (alignment.isNucleotide() && !operation.isNucleotideOperation())
if (inputSeqs == null || inputSeqs.getWidth() <= 0 ||
inputSeqs.getSequences() == null || inputSeqs.getSequences().size() < 1)
inputSeqs = alignment;
-
+
List<SequenceI> seqs = new ArrayList<>();
final boolean submitGaps = operation.isAlignmentAnalysis();
final int minlen = 10;
- int ln = -1;
- // FIXME don't return values by class parameters
+ int ln = -1; // I think this variable is redundant
if (!operation.isAlignmentAnalysis())
seqNames = new HashMap<>();
start = inputSeqs.getStartRes();
for (SequenceI sq : inputSeqs.getSequences())
{
int sqlen;
+ // is it trying to find the length of a sequence excluding gaps?
if (!operation.isAlignmentAnalysis())
+ // why starting at positions to the right from the end/start?
sqlen = sq.findPosition(end + 1) - sq.findPosition(start + 1);
else
sqlen = sq.getEnd() - sq.getStart();
boolean[] tg = gapMap;
gapMap = new boolean[seq.getLength()];
System.arraycopy(tg, 0, gapMap, 0, tg.length);
- for (int p = tg.length; p < gapMap.length; p++)
+ for (int p = tg.length; p < gapMap.length; p++)
{
gapMap[p] = false; // init as a gap
}
{
// TODO: add ability to exclude hidden regions
String sqstring = sq.getSequenceAsString(start, end + 1);
- seq = new Sequence(newName,
+ seq = new Sequence(newName,
AlignSeq.extractGaps(jalview.util.Comparison.GapChars, sqstring));
seqs.add(seq);
// for annotation need to also record map to sequence start/end
}
return seqs;
}
-
+
private boolean checkInputSequencesValid(List<SequenceI> sequences)
{
int nvalid = 0;
FeaturesFile featuresFile;
try
{
+ // I think there should be a better way for obtaining features
+ // Are the features added to the sequences here?
featuresFile = operation.featuresSupplier.getResult(job, sequences, viewport);
if (featuresFile != null)
{
Alignment aln = new Alignment(sequences.toArray(new SequenceI[0]));
+ // I do nothing with the featureFilters object
featuresFile.parse(aln, featureColours, true);
}
} catch (IOException e)
{
aa.setCalcId(service.getName());
}
+ // Can't services other than alignment analysis be interactive?
+ // What's the point of storing that information in the annotation?
aa.autoCalculated = operation.isAlignmentAnalysis() && operation.isInteractive();
}
updateResultAnnotation(outputAnnotations);
{
return featureColours.get(type);
}
-
+
@Override
public FeatureMatcherSetI getFeatureFilters(String type)
{
return featureFilters.get(type);
}
-
+
@Override
public boolean isFeatureDisplayed(String type)
{
}
Cache.log.debug("Annotation service task finished.");
}
-
+
+ // What is the purpose of this method?
+ // When is it called (apart from the above)?
private void updateResultAnnotation(List<AlignmentAnnotation> annotations)
{
var currentAnnotations = Objects.requireNonNullElse(
viewport.getAlignment().getAlignmentAnnotation(),
new AlignmentAnnotation[0]);
List<AlignmentAnnotation> newAnnots = new ArrayList<>();
+ // what is the graph group and why starting from 1?
int graphGroup = 1;
for (AlignmentAnnotation alna : currentAnnotations)
{
ala.graphGroup += graphGroup;
}
+ // stores original sequence, in what case it ends up as null?
SequenceI aseq = null;
if (ala.sequenceRef != null)
{
Annotation[] resAnnot = ala.annotations;
Annotation[] gappedAnnot = new Annotation[Math
.max(viewport.getAlignment().getWidth(), gapMap.length)];
+ // is it adding gaps which were previously removed to the annotation?
for (int p = 0, ap = start; ap < gappedAnnot.length; ap++)
{
if (gapMap != null && gapMap.length > ap && !gapMap[ap])
gappedAnnot[ap] = resAnnot[p++];
}
}
+ // replacing sequence with the original one?
ala.sequenceRef = aseq;
ala.annotations = gappedAnnot;
AlignmentAnnotation newAnnot = viewport.getAlignment()
for (SequenceI sq : sequences)
{
+ // what are DBRefs? why are they relevant here?
if (!sq.getFeatures().hasFeatures() &&
(sq.getDBRefs() == null || sq.getDBRefs().size() == 0))
{
SequenceI seq = seqNames.get(sq.getName());
SequenceI dseq;
ContiguousI seqRange = seq.findPositions(start, end);
-
+
while ((dseq = seq).getDatasetSequence() != null)
{
seq = seq.getDatasetSequence();
}
updateOurAnnots(newAnnots);
}
-
+
protected void updateOurAnnots(List<AlignmentAnnotation> annots)
{
List<AlignmentAnnotation> our = ourAnnots;