Skip to main content

Getting plasmid Genbank files programmatically

Comments

5 comments

  • 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

    FileUtilities.createTempFile(...)

     

    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?

    0
  • 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.

    0
  • Jsr Castrogiovanni

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

    0
  • 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 https://assets.geneious.com/developer/geneious/javadoc/latest/com/biomatters/geneious/publicapi/plugin/DocumentOperation.html.  That'll let you add a button into the UI (menu or toolbar etc) that runs your code.

    0

Please sign in to leave a comment.