Skip to main content

What DocumentType is "Restriction Enzyme Collection"?

Comments

4 comments

  • Geneious Team

    Hi Matthew,

    The Restriction Enzyme Collection document type is defined by our bundled cloning plugin so isn't part of the Geneious public API. To get a reference to it, you can use the following code:

     

    public static DocumentType getDocumentTypeByName(String name) {
    for (GeneiousPlugin plugin : PluginUtilities.getActiveGeneiousPlugins()) {
    for (DocumentType documentType : plugin.getDocumentTypes()) {
    if (documentType.humanReadableName.equals(name))
    return documentType;
    }
    }
    return null;
    }

    getDocumentTypeByName("Restriction Enzyme Collection");

    Best regards,

    Matt.

    0
  • Matthew Shum

    Thanks, Matt!

    This answered my question.

    0
  • Sean Johnson

    Is there a way to access the restriction enzyme names and recognition sites from within a custom plugin? Using the code posted, I can make an option that will allow the user to select the correct type of document:

    options.addDocumentSelectionOption("restrictionEnzymesDocument", "Restriction enzymes document", DocumentSelectionOption.FolderOrDocuments.EMPTY, restriction_enzyme_collection_doctype, fieldsToDisplay, false, Collections.emptyList());

    But I can't figure out how make the data in the document available to other functions and classes.

    It throws an exception when I add the following line:

    public List<AnnotatedPluginDocument> performOperation(AnnotatedPluginDocument[] documents,
                ProgressListener progressListener, Options options) throws DocumentOperationException {
    ...
    ...
    ArrayList<AnnotatedPluginDocument> selectedEnzymesDocument = (ArrayList<AnnotatedPluginDocument>) ((DocumentSelectionOption) options.getValue("restrictionEnzymesDocument")).getDocuments();
    0
  • Moreland Gibbs

    Sean,

    You will have to get the actual DocumentSelectionOption first before you can call getValue() or getDocuments() on it. So in your call, if you replace 'getValue' with 'getOption' it should work (depending on where in the options you added the documentSelectionOption. If you've added them to childOptions you'll have to prefix it correspondingly.)

    ArrayList<AnnotatedPluginDocument> selectedEnzymesDocument = (ArrayList<AnnotatedPluginDocument>) ((DocumentSelectionOption) options.getOption("restrictionEnzymesDocument")).getDocuments();

    Since EnzymeDocuments are not in the PublicAPI you will have to access information via xml.

    You can call something like this:

    ArrayList<PluginDocument> selectedEnzymesDocument = new ArrayList<>();
    for (PluginDocument enzymeDocument : selectedEnzymesDocument) {
    Element enzymesElement = enzymeDocument.toXML();
    String recognitionSequence = enzymesElement.getChild("enzymes").getChild("enzyme").getChildText("recognitionSequence");
    }

    To get more info about the whole xml and which kind of elements are in there, you can convert it into a string and print it out using 

    String humanReadableXml = StringUtilities.formatElement(enzymesElement);

     

     
    0

Please sign in to leave a comment.