Skip to main content

Ordering of AnnotatedPluginDocuments in GoldenGateOperation

Comments

4 comments

  • Official comment
    Jonas Kuhn

    Hi Alex,

    sorry for the delayed reply, it's been a few quite busy days.

    Firstly: 

    goldenopts.setStringValue("vectorOption", "");

    is the correct way to make sure that the backbone is empty.
    If you wanted to set a specific sequence as vector, you can pass in the URN of that sequence

    goldenopts.setStringValue("vectorOption", vectorDocument.getURN().toString());


    Now, for document sorting:
    The 'natural' sorting of `annotatedDocuments` is often based on where in the document table the document is (i.e. the document listed at the top is usually (not reliably always though) the first in the list/array. It would be a good idea to have your own sorting before passing those documents to the goldenopts.
    Then, usually Golden Gate tries a few ways to adjust the sorting such that the products make sense, e.g. if would look at identified overhangs and try to arrange sequences with matching overhangs to be next to each other. Also, it tries to restore the order of sequences based on past runs.
    Both of those auto-sortings can be circumvented by encapsulating the call to the options with `CommonUtilities.setRunningFromScript(true/false)` :

    Options goldenopts;
    try {
    CommonUtilities.setRunningFromScript(true);
    goldenopts = goldengate.getOptions(documents);
    goldenopts.setStringValue("vectorOption", "None");
    goldenopts.setStringValue("circularProduct", "false");
    } finally {
    CommonUtilities.setRunningFromScript(false);
    }

    It's important to set this to 'false' afterwards again (best in a `try/finally` block), so that other operations don't wrongly assume they're running from script as well.

    This would still depending on how well you can control the sorting of documents before passing those to the options. In order to do that reliably, we would recommend to either create some custom options that would allow your users to sort the documents manually, OR you could just directly expose the GoldenGate options to your users by implementing getOptions():

    @Override
    public Options getOptions(AnnotatedPluginDocument... documents) throws DocumentOperationException {
    DocumentOperation goldengate = PluginUtilities.getDocumentOperation("com.biomatters.plugins.cloning.goldengate.GoldenGateOperation");
    return goldengate.getOptions(documents);
    }

     

    Whether you'd want to expose the cloning options depends of course on the purpose of your plugin.

    I hope this helps, happy coding.

  • Ashfaq Indragadia

    Instead of the below line, you can try getGeneralOptions() method.
    Options goldenopts = goldengate.getOptions(documents);

    The getGeneralOptions() method should cause it to behave like workflows.

    Do let us know if this does not work or if you face any other issues. 

     

    0
  • Alex Zwetsloot

    Hi Mohmed,

    Thanks for your response. Please could you explain how to work with .getGeneralOptions()? I tried below, and I get an outOfBounds exception. I also tried making the general options into an XML object and merging them with the specific options using valuesFromXML() as I saw this mentioned in the documentation. In this case the function works but the insertNames option is still in a random order.

    Can I also check my value for vectorOption is valid? Setting as "" returned true, but setting as "None" or anything else returned false.

    Thanks!

    Alex

    private AnnotatedPluginDocument ggAssembleLinear(AnnotatedPluginDocument[] documents) throws DocumentOperationException {
    DocumentOperation goldengate = PluginUtilities.getDocumentOperation("com.biomatters.plugins.cloning.goldengate.GoldenGateOperation");
    Options goldenopts = goldengate.getGeneralOptions();
    goldenopts.setStringValue("vectorOption", "");
    goldenopts.setStringValue("circularProduct", "false");
    goldenopts.setStringValue("runFromWorkflowOption", "true");
    List<AnnotatedPluginDocument> result = goldengate.performOperation(documents, ProgressListener.EMPTY, goldenopts);
    return result.get(0);
    }

    Gives: 15:44:35.281 WARNING: Exception: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
        at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
        at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
        at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
        at java.base/java.util.Objects.checkIndex(Objects.java:372)
        at java.base/java.util.ArrayList.get(ArrayList.java:459)
        at com.biomatters.plugins.cloning.sharedCloning.CloningOperation.performOperation(CloningOperation.java:120)
        at com.biomatters.geneious.publicapi.plugin.DocumentOperation.performOperation(DocumentOperation.java:447)
        at com.biomatters.geneious.publicapi.plugin.DocumentOperation.performOperation(DocumentOperation.java:376)
        at com.biomatters.GSKMammalianHTX.submodules.CustomCombinationBuilder.ggAssembleLinear(CustomCombinationBuilder.java:231)
    0
  • Alex Zwetsloot

    Thanks for your help team. I'd still be interested to understand how to implement getGeneralOptions(), but I've tackled this specific problem in a different way by making my own Golden Gate assembly logic.

    Best, Alex

    0

Please sign in to leave a comment.