Skip to main content

Getting AnnotatedPluginDocument from SequenceList members

Comments

5 comments

  • Alex Zwetsloot

    Hello,

    I've tried to debug this further and have noticed something strange.

    Sequence lists I make through the UI (right click -> Group Sequences into a List...) or by batch function (in this case, Golden Gate/Type IIS cloning results list) do not have findable AnnotatedPluginDocuments on the individual nucletodie sequences within the list and return null. I had assumed the original AnnotatedPluginDocument that was used to make the sequence list would be findable.

    Sequence lists that I have made from within one of my plugins by calling DocumentUtilities.createAnnotatedPluginDocuments on a DefaultSequenceListDocument all have findable AnnotatedPluginDocuments when I iterate over the nucletoide sequence lists.

    Is this just a fundamental part of how Geneious Prime works that I'm misunderstanding? I have DocumentFields on the documents within the SequenceLists I'm trying to access and so thats my use case.

    Thanks,

    Alex

    0
  • Ashfaq Indragadia

    Unfortunately, this method will not work in this situation because the sequences were not returned directly from the getDocument() method. They are in fact an extra level deeper. Geneious does not track the relationship down to this level. 

    We suggest you keep a copy of the documents in a map or similar, for you to look up.

    Let us know if you need further assistance. 

    0
  • Alex Zwetsloot

    Thanks for your response Mohmed. Will do as you suggested.

    Do you know why some sequence lists, generated in plugins, let me find an AnnotatedPluginDocument when I iterate over them, whereas the ones I made in the UI don't?

    0
  • Richard Moir

    Hey Alex, I just had a quick go at reproducing your observation and it was still null. Can you share a code snippet to demonstrate?

    0
  • Alex Zwetsloot

    Hi Richard, 

    I'm struggling to recreate, which means I probably don't understand the exact cases in which I'm seeing this. If you take this example of a DocumentOperation below, I pass in whatever SequenceListDocument I'm clicking and loop through it. If I pass it a manually grouped sequence list from the UI, or a parts cloned sequence list output, they are all null, as we would expect based on the behaviour you have described.

    If I pass it a SequenceListDocument that was generated from one of my custom plugins, it doesn't return null.

    In my custom plugins, I create a DefaultSequenceListDocument and then add AnnotatedPluginDocuments to it with the .addNucleotideSequence() command. I notice there is also a command to call addNucleotideSequence() with a NucleotideSequenceDocument. Perhaps this is the thing that explains why some sequence lists are unable to return references to APDs and others aren't?

    Please note that this isn't blocking anything for me anymore as I've taken an alternative approach, so really its just out of interest at this stage.

    Thanks,

    Alex

    public List<AnnotatedPluginDocument> performOperation(AnnotatedPluginDocument[] documents,
    ProgressListener progressListener, Options options) throws DocumentOperationException {

    AnnotatedPluginDocument sequenceList = documents[0];
    Set<URN> referencedDocuments = sequenceList.getReferencedDocuments();
    // Check referenced documents to see how this sequence list was generated:
    for (URN urn : referencedDocuments) {
    AnnotatedPluginDocument testDocument = DocumentUtilities.getDocumentByURN(urn);
    if (testDocument.getName().equals("Group Sequences into a List")) {
    System.out.println("This sequence list came from a UI-based group sequence list command.");
    } else if (testDocument.getName().equals("Parts Cloning")) {
    System.out.println("This sequence list came from a Parts Cloning operation.");
    }
    printListDocuments(sequenceList);
    }
    return null;
    }

    private void printListDocuments(AnnotatedPluginDocument sequenceListAPD) {
    SequenceListDocument sequenceListDoc = (SequenceListDocument) sequenceListAPD.getDocumentOrNull();
    List<NucleotideSequenceDocument> sequenceList = sequenceListDoc.getNucleotideSequences();
    for (NucleotideSequenceDocument doc : sequenceList) {
    AnnotatedPluginDocument apd = DocumentUtilities.getAnnotatedPluginDocumentThatContains(doc);
    if (apd != null) {
    System.out.println(apd.getName());
    } else {
    System.out.println("Document is null");
    }

    }
    }
    0

Please sign in to leave a comment.