obtaining the user's data file path
This is a locked post that has been migrated from our previous forum. Please start a new post if you would like to continue the discussion.
Geneious User:
I've just finished writing a plugin for spa typing S. aureus (an annotation generator) which uses two data files containing the spa repeats and the spa type patterns. I'd like the user to place these in the plugin folder in the user's data folder but can't see an obvious way to obtain the path (I'm probably just missing something obvious). Can any one advise me?
I'm also happy for the plug in to be put in the public domain. The reason I wrote it is that there is no easy low cost solution for obtaining spa types from sequence data and a combination of geneious and a plugin is a good solution. How does one go about submitting a plugin for distribution?
Many thanks.
Geneious Support:
No, it's not obvious. Here's an example from my Glimmer plugin since I needed the plugin to find the location of the executable:
public static String getPathToExecutableFolder() throws DocumentOperationException {
String folderName = getExecutableFolderName();
URL resource = GlimmerPlugin.class.getResource(folderName);
if(resource != null) {
return resource.getFile().replace("%20", " ") + File.separator;
} else {
throw new IllegalStateException("Executable folder " + folderName + " missing from Glimmer plugin.");
}
}
That should give you an idea of how to get the plugin folder.
Shane
Geneious Support:
The folder provided by Shane's code will give you the path to files where your plugin is installed. However, if the plugin was installed by an admin user, the user may not have write access to that folder.
You can also use the pluginUserDirectory parameter passed to GeneiousPlugin.initialize for storing custom data in a folder specific to your plugin that the user is guaranteed to have write access to.
It would be great if you shared your plugin. Send it to support@geneious.com and we'll evaluate it and as long as nothing is seriously wrong with it we'll include it in our plugins page and make it available from the plugin manager within Geneious.
Geneious User:
Many thanks. I'll give it a go and let you know how I got on.
Geneious User:
Sorry having read your responses more carefully I realise that I should have made my self clearer. What I was thinking of doing was asking the users to put the the two files in the user's data folder (e.g the users/user account/Geneious 5.6 Data/Plugins. On my mac this is an empty folder and would seem a good place to put the data files for the plugin. By keeping the files (which are downloadable from the Ridom web pages) in an easily locatable folder users can download updated spa type data as it become available. I really just wanted access to the Data Storage location set in general preferences.
Geneious Support:
If they're going to update it regularly, why not just let them put it where they feel it is convenient and have your plugin browse to that location and remember it? If you've done the Phobos plugin you'll have seen code to do this early on when locating the Phobos binary.
Shane
Geneious User:
I hasten to add that I'm a very naive programmer but was very pleasantly surprised by the ease with which I could adapt the annotation generator example to do what I wanted to do (with a bit of help from the internet). At the moment I just use the default path which requires me to ctrl click and open the application package and put the files inside the Geneious/contents/resources folder. However I think it's a bit unreasonable to expect users to do this. Also I'm not sure how this would work for linux or windows users.
Geneious Support:
Indeed, which is why I think you should have a chooser in your options for the location of the data.
Shane
Geneious User:
I wanted to avoid having to set up a dialog box to locate the data files every time the user ran the annotator. At the moment it is a single menu action which results in an annotated sequence providing not only the spa type but also showing how it is made up. This is valuable as, should the user come across an unusual spa type, or the plugin have produced an anomalous result due to homology elsewhere in the sequence they should easily spot it as they have the full diagrammatic view. I have about 100 at a time to go through so a quick and easy interface would be preferred. The spa type database only changes minimally and so updating it wouldn't be a frequent occurrence.
Geneious User:
I'd also like to avoid having to complicate the error message that is generated when the data files are missing. Easier to tell them "file should be in the plugin folder in your geneious data folder" rather than "it isn't in the folder where you said it would be"? I imagined that this was what the plugin folder might be for.
Geneious Support:
You wouldn't have to run it every time, just put it in the options like Phobos does and the location will be remembered. Make sure that like the Phobos binary dialogue, this one is set to not be reset if the user restores defaults and it should be fine. If there isn't actually an options dialogue that comes up when the operation is run, you could create one that only shows up when the location isn't currently known.
Shane
Geneious User:
One last thing. I'd also like to avoid having to store any private data for the plugin. This is a quick and dirty solution of interest for researchers rather than a commercial product for hospitals (they have the readies to pay for the Ridom package or Bionumerics (to use the 'free' plugin)).
May be I'm just lazy.
Geneious User:
Sorry messages out of sync here. Although I can see that I could set a flag to ask the user the first time they use the plug in to provide a location. How would I enable them to change it later?
Geneious Support:
You wouldn't be storing any private data yourself. The plugin will store their private info in their own database.
Shane
Geneious Support:
I guess the simple answer is if they delete the previous spa repeats file and run it again then there won't be anything so it would trigger the dialogue again. They could put a new copy in another folder. Messy. Usually an operation like this would have an options dialogue that always comes up so they could easily reset it as the dialogue would appear each time with some options for them to choose and then they would run it.
Shane
Geneious User:
I guess you're right and I'll have a go. But could you indulge me, if only for a temporary fix, and tell me is it possible to obtain the location of the user's data folder, and if so, how?
Geneious User:
From an ergonomic point of view I think you are absolutely correct. I guess I'll just have to bite the bullet and get on with it. As a first time java programmer I just hate having to head back up the steep learning curve again!
Geneious Support:
Well, you can put this in your GeneiousPlugin. This is from my MafftPlugin:
@Override
public void initialize(File pluginUserDirectory, File pluginDirectory) {
super.initialize(pluginUserDirectory, pluginDirectory);
this.pluginUserDirectory = pluginUserDirectory;
}
You now have a variable which the plugin knows and you can display for the user so they can put their data inside that folder.
Shane
Geneious User:
Many thanks Shane,
I'll use that as a default that populates the startup option the first time the plugin is used but allow the user to choose any location as you suggest. (I'm off to bed now, probably mid morning for you).
Geneious Support:
Just coming up to 10am, but I've been here for 2.5 hours already (early starter). Anyway, worth a go. In the end, having a dialogue where they can specify the location is your best solution but if you need to tell them where to put the data manually within the plugins folder giving them a prompt as to where it should be.
Shane
Geneious User:
I've just sent an email containing the spa typing plugin including the source and some sequence files.
One thing I couldn't work out how to do was to set the value of the combo box option type. I needed to change it's setting when one of the other options was selected. I expected to be able to use the string to set it's value but obviously it needed a different data type that I couldn't work out.
A combination of your Phobos example and the Eclipse/API/Java combination made it very straightforward and although it was a steep learning curve I was surprised how quickly I made progress even with no experience of Java. Having said that, no professional would be impressed with the style.
Thanks for your help
Mark
Geneious Support:
Hi Mark,
Has your plugin turned out well? I don't think we ever received the plugin via email if you sent it to us.
Geneious User:
Many apologies Shane. The plugin seems to work well (we've been using it for our own work). I haven't made the modifications you suggested yet but will send you a current copy for your comments before tidying it up for distribution.
Mark
Geneious User:
Doh! I meant Richard of course.
Geneious User:
I've just finished writing a plugin for spa typing S. aureus (an annotation generator) which uses two data files containing the spa repeats and the spa type patterns. I'd like the user to place these in the plugin folder in the user's data folder but can't see an obvious way to obtain the path (I'm probably just missing something obvious). Can any one advise me?
I'm also happy for the plug in to be put in the public domain. The reason I wrote it is that there is no easy low cost solution for obtaining spa types from sequence data and a combination of geneious and a plugin is a good solution. How does one go about submitting a plugin for distribution?
Many thanks.
Geneious Support:
No, it's not obvious. Here's an example from my Glimmer plugin since I needed the plugin to find the location of the executable:
public static String getPathToExecutableFolder() throws DocumentOperationException {
String folderName = getExecutableFolderName();
URL resource = GlimmerPlugin.class.getResource(folderName);
if(resource != null) {
return resource.getFile().replace("%20", " ") + File.separator;
} else {
throw new IllegalStateException("Executable folder " + folderName + " missing from Glimmer plugin.");
}
}
That should give you an idea of how to get the plugin folder.
Shane
Geneious Support:
The folder provided by Shane's code will give you the path to files where your plugin is installed. However, if the plugin was installed by an admin user, the user may not have write access to that folder.
You can also use the pluginUserDirectory parameter passed to GeneiousPlugin.initialize for storing custom data in a folder specific to your plugin that the user is guaranteed to have write access to.
It would be great if you shared your plugin. Send it to support@geneious.com and we'll evaluate it and as long as nothing is seriously wrong with it we'll include it in our plugins page and make it available from the plugin manager within Geneious.
Geneious User:
Many thanks. I'll give it a go and let you know how I got on.
Geneious User:
Sorry having read your responses more carefully I realise that I should have made my self clearer. What I was thinking of doing was asking the users to put the the two files in the user's data folder (e.g the users/user account/Geneious 5.6 Data/Plugins. On my mac this is an empty folder and would seem a good place to put the data files for the plugin. By keeping the files (which are downloadable from the Ridom web pages) in an easily locatable folder users can download updated spa type data as it become available. I really just wanted access to the Data Storage location set in general preferences.
Geneious Support:
If they're going to update it regularly, why not just let them put it where they feel it is convenient and have your plugin browse to that location and remember it? If you've done the Phobos plugin you'll have seen code to do this early on when locating the Phobos binary.
Shane
Geneious User:
I hasten to add that I'm a very naive programmer but was very pleasantly surprised by the ease with which I could adapt the annotation generator example to do what I wanted to do (with a bit of help from the internet). At the moment I just use the default path which requires me to ctrl click and open the application package and put the files inside the Geneious/contents/resources folder. However I think it's a bit unreasonable to expect users to do this. Also I'm not sure how this would work for linux or windows users.
Geneious Support:
Indeed, which is why I think you should have a chooser in your options for the location of the data.
Shane
Geneious User:
I wanted to avoid having to set up a dialog box to locate the data files every time the user ran the annotator. At the moment it is a single menu action which results in an annotated sequence providing not only the spa type but also showing how it is made up. This is valuable as, should the user come across an unusual spa type, or the plugin have produced an anomalous result due to homology elsewhere in the sequence they should easily spot it as they have the full diagrammatic view. I have about 100 at a time to go through so a quick and easy interface would be preferred. The spa type database only changes minimally and so updating it wouldn't be a frequent occurrence.
Geneious User:
I'd also like to avoid having to complicate the error message that is generated when the data files are missing. Easier to tell them "file should be in the plugin folder in your geneious data folder" rather than "it isn't in the folder where you said it would be"? I imagined that this was what the plugin folder might be for.
Geneious Support:
You wouldn't have to run it every time, just put it in the options like Phobos does and the location will be remembered. Make sure that like the Phobos binary dialogue, this one is set to not be reset if the user restores defaults and it should be fine. If there isn't actually an options dialogue that comes up when the operation is run, you could create one that only shows up when the location isn't currently known.
Shane
Geneious User:
One last thing. I'd also like to avoid having to store any private data for the plugin. This is a quick and dirty solution of interest for researchers rather than a commercial product for hospitals (they have the readies to pay for the Ridom package or Bionumerics (to use the 'free' plugin)).
May be I'm just lazy.
Geneious User:
Sorry messages out of sync here. Although I can see that I could set a flag to ask the user the first time they use the plug in to provide a location. How would I enable them to change it later?
Geneious Support:
You wouldn't be storing any private data yourself. The plugin will store their private info in their own database.
Shane
Geneious Support:
I guess the simple answer is if they delete the previous spa repeats file and run it again then there won't be anything so it would trigger the dialogue again. They could put a new copy in another folder. Messy. Usually an operation like this would have an options dialogue that always comes up so they could easily reset it as the dialogue would appear each time with some options for them to choose and then they would run it.
Shane
Geneious User:
I guess you're right and I'll have a go. But could you indulge me, if only for a temporary fix, and tell me is it possible to obtain the location of the user's data folder, and if so, how?
Geneious User:
From an ergonomic point of view I think you are absolutely correct. I guess I'll just have to bite the bullet and get on with it. As a first time java programmer I just hate having to head back up the steep learning curve again!
Geneious Support:
Well, you can put this in your GeneiousPlugin. This is from my MafftPlugin:
@Override
public void initialize(File pluginUserDirectory, File pluginDirectory) {
super.initialize(pluginUserDirectory, pluginDirectory);
this.pluginUserDirectory = pluginUserDirectory;
}
You now have a variable which the plugin knows and you can display for the user so they can put their data inside that folder.
Shane
Geneious User:
Many thanks Shane,
I'll use that as a default that populates the startup option the first time the plugin is used but allow the user to choose any location as you suggest. (I'm off to bed now, probably mid morning for you).
Geneious Support:
Just coming up to 10am, but I've been here for 2.5 hours already (early starter). Anyway, worth a go. In the end, having a dialogue where they can specify the location is your best solution but if you need to tell them where to put the data manually within the plugins folder giving them a prompt as to where it should be.
Shane
Geneious User:
I've just sent an email containing the spa typing plugin including the source and some sequence files.
One thing I couldn't work out how to do was to set the value of the combo box option type. I needed to change it's setting when one of the other options was selected. I expected to be able to use the string to set it's value but obviously it needed a different data type that I couldn't work out.
A combination of your Phobos example and the Eclipse/API/Java combination made it very straightforward and although it was a steep learning curve I was surprised how quickly I made progress even with no experience of Java. Having said that, no professional would be impressed with the style.
Thanks for your help
Mark
Geneious Support:
Hi Mark,
Has your plugin turned out well? I don't think we ever received the plugin via email if you sent it to us.
Geneious User:
Many apologies Shane. The plugin seems to work well (we've been using it for our own work). I haven't made the modifications you suggested yet but will send you a current copy for your comments before tidying it up for distribution.
Mark
Geneious User:
Doh! I meant Richard of course.
0
Post is closed for comments.
Comments
0 comments