Post

2 followers Follow
0
Avatar

Importing GFF file from URL, using a Plugin

I am creating a Plugin to access an API that returns a GFF file. I am able to run the API and retrieve the GFF file. I can currently, display the same as a text file in the geneious. However, before I code a parser to convert the GFF file into annotations on the sequences, is there a in built importer function in Geneious which can automatically import the GFF file form Java.io File object.  If yes, can you provide me with a sample code on how to do this? 

 

Few more details, the API returns a download URL once the analysis is complete. I use JAVA BufferedInputStream to download the file contents and create a Java.io File (gffResult) using the downloaded content.

Then create a text document like so:

public void performOperation(AnnotatedPluginDocument[] documents,
ProgressListener progressListener,
Options options, SequenceSelection sequenceSelection, OperationCallback callback)
throws DocumentOperationException {

PluginDocument Result = new TextDocument(gffResult,"GffOutput", TextDocument.Format.Plain);

GeneiousService selectedService = ServiceUtilities.getSelectedService();

try {
if (selectedService instanceof WritableDatabaseService) {
WritableDatabaseService service = (WritableDatabaseService) selectedService;
service = service.createChildFolder("Results");
service.addDocumentCopy(DocumentUtilities.createAnnotatedPluginDocument(Result),ProgressListener.EMPTY);
}
else {
callback.setSubFolder("Results"); // This doesn't support sub-folders
callback.addDocument(Result, false, ProgressListener.EMPTY);
}
} catch (DatabaseServiceException e) {
throw new DocumentOperationException(e);
}

}

Jagannathan Alagurajan

Official comment

Avatar

Hi,

There's indeed already a GFF parser in Geneious.

You can simply call

PluginUtilities.importDocuments(gffResult, progressListener);


The importer will automatically detect that the file is in GFF format, and apply the results accordingly, so you don't have to transform it to a TextDocument.

It will take the currently selected folder as the destination, if you want to put the results into a subfolder you will have to set that folder as the selected service before calling the importer.

Also, if the resulting annotations are supposed to be applied onto an already existing sequence, that sequence should be present in that folder, or even better, should be the selected document.

The importer will automatically detect the most suitable sequence to apply the annotations to, based on the name in the GFF file and what is currently selected or available in the selected folder, if it doesn't find a sequence with matching name to what's specified in the GFF file it will show a dialog to ask for user confirmation.

I hope that helps, please let us know if you have further questions.

Jonas Kuhn
Comment actions Permalink

Please sign in to leave a comment.

1 comment