Skip to main content

Getting plasmid Genbank files programmatically



  • Official comment
    Jonas Kuhn

    Hi, you can get an exporter for GenBank File Format using this command: 

    DocumentFileExporter genbankExporter = PluginUtilities.getDocumentFileExporter("com.biomatters.plugins.ncbi.importexport.genbankflatexporter.GenBankFlatExporter");
    if (genbankExporter != null) { \\ If the plugin is disabled this might be null
    Options exportOptions = genbankExporter.getOptions(annotatedPluginDocumentList);
    genbankExporter.export(fileToExportTo, myNucleotideDocuments, ProgressListener.EMPTY, exportOptions);


    Then you would need to get the content of `fileToExportTo` and pass it to your API.

    If you don't need the actual file after that, you can use



    For your second question about `getSelectedDocuments()` being empty, that sounds like something is going wrong, it should not be empty if you have documents selected.

    Could you give us more details about that (e.g. is the list always empty, or only in certain situations?) and possibly add some logging to your code?

  • Jsr Castrogiovanni

    Also, getSelectedDocuments() returns an empty list, even though multiple documents are checked on the document table. Why would that be?

  • Jsr Castrogiovanni

    Thank you Jonas!

    When I call getSelectedDocuments, I'm doing it from a service.

    I go to the document table, select 2 plasmids with the blue checkboxes, then go to my service and click the button in the panel (it's a GeneiousServiceWithPanel) to start execution, but DocumentUtilities.getSelectedUtilities() is empty. This is the only context is which I use this method in my plugin, and I've confirmed that the list of returned documents is in fact empty using a console print statement.

  • Jsr Castrogiovanni

    In the second reference there, I meant to say getSelectedDocuments again, not getSelectedUtilities, sorry for the typo.

  • Matthew Cheung

    It sounds like the problem is that you're unselected the documents by selecting your new service.

    You might be better off implementing this as a DocumentOperation  That'll let you add a button into the UI (menu or toolbar etc) that runs your code.


Please sign in to leave a comment.