Post

2 followers Follow
0
Avatar

How to remove annotations

 I'm tying to remove some annotations I created. They are marked with a qualifier.

I cannot seem to find a method clearAnno.. or deleteAnno.. or removeAnno.. etc.

I also tried:

AnnotationGeneratorResult annotationGeneratorResult = new AnnotationGeneratorResult();
gemAnnotations.forEach(annotationGeneratorResult::addAnnotationToRemove);


defaultAlignmentDocument.getSequence(i).getSequenceAnnotations().clear();

((SequenceDocumentWithEditableAnnotations)defaultAlignmentDocument.getSequence(i)).setAnnotations(Collections.emptyList())
I tried to also add a doc.sve but that did not help.



none worked. Last one with class cast exception.

I need to do that from a new Operation.


Thank you,
Adrian
Adrian

Please sign in to leave a comment.

2 comments

0
Avatar

Hi Adrian,

 

The AnnotationGeneratorResult approach will only work if you're returning that AnnotationGeneratorResult from a SequenceAnnotationGenerator. But it sounds like you need to do this in a DocumentOperation, in which case the way to do it is like this:

public void removeAnnotations(AnnotatedPluginDocument alignmentDocument, int sequenceIndex) throws DocumentOperationException {
SequenceAlignmentDocument alignment = (SequenceAlignmentDocument) alignmentDocument.getDocument();
if (alignment.canSetAnnotations()) {
List<SequenceAnnotation> sequenceAnnotations = new ArrayList<>(alignment.getSequence(sequenceIndex).getSequenceAnnotations());
// remove the annotations you want to remove from sequenceAnnotations here
alignment.setAnnotations(sequenceIndex, sequenceAnnotations, true);
alignmentDocument.save();
}
}

Best regards,

Matt.

Geneious Team 0 votes
Comment actions Permalink