Post

4 followers Follow
0
Avatar

What DocumentType is "Restriction Enzyme Collection"?

Hello,

I am looking to add a Restriction Enzyme from the Restriction Enzyme Collection to a workflow via addDocumentSelectionOption().

What DocumentType is Restriction Enzyme?

Matthew Shum

Please sign in to leave a comment.

4 comments

0
Avatar

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.

Geneious Team 0 votes
Comment actions Permalink
0
Avatar

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();
Sean Johnson 0 votes
Comment actions Permalink
0
Avatar

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);

 

 
Moreland Gibbs 0 votes
Comment actions Permalink