Creating a sub-folder & saving documents in a SequenceAnnotationGenerator
I'm updating a SequenceAnnotationGenerator plugin that among other things is creating a couple of new documents and using the `AnnotationGeneratorResult.addGeneratedDocument()` method to add them to the current local folder.
What I'd like to do instead is to create a new sub-folder with a given name and save the `AnnotatedPluginDocument` there. I've found all sorts of pieces that look like they get me almost there but havent' yet managed to put them together in a way that works.
For instance I see `DocumentOperation.performOperation` has a callback field that looks to be exactly what I want, but of course this isn't a `DocumentOperation`.
Is there a way within this construct to save new documents to a subfolder? I can look at creating a new DocumentOperation that gets called by my SequenceAnnotationGenerator, but I don't want to expose this to the outside world - is this really the right path?
-
Ok, so the following appears to be working. Are there any gotchas I should be aware of here?
WritableDatabaseService service = (WritableDatabaseService)annotatedPluginDocuments[0].getDatabase();
WritableDatabaseService subfolder = service.createChildFolder("SUBFOLDER");
subfolder.addDocumentCopy(theNewDocument, ProgressListener.EMPTY);0 -
Another question I have here is if it's possible to instead of annotating the original document to instead annotate a copy of the original document in the subfolder?
0 -
Hi Jeff,
Manually creating the sub-folder and saving into it should be fine. If you're sticking with a SequenceAnnotationGenerator then I don't think there is an automatic way to annotate a copy. Although a copy will be created if the annotation generator is invoked as part of a workflow.
If you're always going to be annotating a copy, then you may want to switch to a DocumentOperation. Then you can use the callback to specify the subfolder and just add the result to the callback.
0 -
Got it. I did explore the idea of converting the whole thing to a `DocumentOperation` but wasn't sure if it'd work. Right now I have a plugin that:
- Takes in a sequence selection on a document
- Generates some annotations for that document based on the selection
- Generates a few new documents
- Adds the new annotations as a track to the original document
So instead this would make copy of the original document, and add the generated annotations to the copy.
It wasn't clear to me how I"d go about adding the new track & annotations to the copied document however.
Also I think this would mean that the plugin action would no longer reside in "Annotate & Predict', correct?0 -
Yes that sounds right. It comes down to whether or not you want to add annotations to the original or not.
Regardless of the base class it sounds like you'd still need to do the copy and adding of annotations "manually" to achieve what you want. So something like this:
DefaultSequenceDocument copy = SequenceUtilities.createSequenceCopyEditable(sequenceToCopy);
copy.setAnnotations(newAnnotations);
SequenceTrack.Manager trackManager = copy.getTrackManager(false);
trackManager.addTrack(new SequenceTrack("MyTrack").setAnnotations(trackAnnotations));The class you use has no effect on where in the menus your action appears. You can specify GeneiousActionOptions.MainMenu.html#AnnotateAndPredict when creating the GeneiousActionOptions.
0
Please sign in to leave a comment.
Comments
5 comments