Skip to main content

Creating a sub-folder & saving documents in a SequenceAnnotationGenerator

Comments

5 comments

  • Jeff Gentry

    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
  • Jeff Gentry

    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
  • Matthew Cheung

    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
  • Jeff Gentry

    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:

    1. Takes in a sequence selection on a document
    2. Generates some annotations for that document based on the selection
    3. Generates a few new documents
    4. 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
  • Matthew Cheung

    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.