import jalview.schemes.ResidueColourScheme;
import jalview.schemes.TCoffeeColourScheme;
import jalview.util.MessageManager;
-import jalview.util.StringUtils;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.ViewportRanges;
import jalview.ws.DBRefFetcher;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.List;
-import java.util.Scanner;
import java.util.Vector;
import javax.swing.JCheckBoxMenuItem;
return true;
}
+ /**
+ * Opens a file browser and adds the selected file, if in Fasta, Stockholm or
+ * Pfam format, to the list held under preference key "HMMSEARCH_DBS" (as a
+ * comma-separated list)
+ */
@Override
public void addDatabase_actionPerformed() throws IOException
{
- if (Cache.getProperty(Preferences.HMMSEARCH_DB_PATHS) == null)
+ if (Cache.getProperty(Preferences.HMMSEARCH_DBS) == null)
{
Cache.setProperty(Preferences.HMMSEARCH_DBS, "");
- Cache.setProperty(Preferences.HMMSEARCH_DB_PATHS, "");
}
String path = openFileChooser(false);
if (format == FileFormat.Fasta || format == FileFormat.Stockholm
|| format == FileFormat.Pfam)
{
- String currentDbs = Cache.getProperty(Preferences.HMMSEARCH_DBS);
String currentDbPaths = Cache
- .getProperty(Preferences.HMMSEARCH_DB_PATHS);
- currentDbPaths += " " + path;
-
- String fileName = StringUtils.getLastToken(path, File.separator);
- Scanner scanner = new Scanner(fileName).useDelimiter(".");
- String name = scanner.next();
- scanner.close();
- currentDbs += " " + path; // TODO remove path from file name
- scanner.close();
-
- Cache.setProperty(Preferences.HMMSEARCH_DB_PATHS, currentDbPaths);
+ .getProperty(Preferences.HMMSEARCH_DBS);
+ currentDbPaths += Preferences.COMMA + path;
Cache.setProperty(Preferences.HMMSEARCH_DBS, currentDbPaths);
}
else
import jalview.ws.params.simple.Option;
import jalview.ws.params.simple.StringParameter;
+import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.List;
import java.util.Scanner;
/*
* 'Options'
*/
- addChoiceOfHmm(args);
-
- String names = Cache.getProperty(Preferences.HMMSEARCH_DBS);
- if (names != null && !names.isEmpty())
- {
- List<String> databases = new ArrayList<>();
- databases.add(MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY));
- Scanner nameScanner = new Scanner(names);
-
- if (nameScanner.hasNext())
- {
- while (nameScanner.hasNext())
- {
- String next = nameScanner.next();
- if ("null".equals(next))
- {
- Cache.setProperty(Preferences.HMMSEARCH_DBS, "");
- Cache.setProperty(Preferences.HMMSEARCH_DB_PATHS, "");
- }
- else
- {
- databases.add(next);
- }
- }
- }
- nameScanner.close();
- args.add(new StringParameter(
- MessageManager.getString(HMMSearch.DATABASE_KEY),
- MessageManager.getString("label.database_for_hmmsearch"),
- true, MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY),
- MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY),
- databases));
- }
args.add(new BooleanOption(
MessageManager.getString(HMMSearch.AUTO_ALIGN_SEQS_KEY),
MessageManager.getString("label.auto_align_seqs_desc"), false,
/*
* 'Parameters'
*/
+ addChoiceOfHmm(args);
+
+ addChoiceOfDatabase(args);
+
args.add(new IntegerParameter(
MessageManager.getString(HMMSearch.NUMBER_OF_RESULTS_KEY),
MessageManager.getString("label.number_of_results_desc"), true,
MessageManager.getString(HMMSearch.REPORTING_CUTOFF_KEY), null,
true, HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_NONE,
Arrays.asList(HMMSearch.CUTOFF_NONE, HMMSearch.CUTOFF_EVALUE,
- HMMSearch.CUTOFF_SCORE)));
+ HMMSearch.CUTOFF_SCORE),
+ null));
args.add(new LogarithmicParameter(
MessageManager.getString(HMMSearch.SEQ_EVALUE_KEY),
MessageManager.getString("label.seq_e_value_desc"), false, 1D,
}
/**
+ * Constructs a choice parameter for database to search; always includes 'this
+ * alignment', and also includes any databases held under user preferences key
+ * "HMMSEARCH_DBS" as a comma-delimited list
+ *
+ * @param args
+ */
+ protected void addChoiceOfDatabase(List<ArgumentI> args)
+ {
+ String names = Cache.getProperty(Preferences.HMMSEARCH_DBS);
+ if (names == null || names.isEmpty())
+ {
+ return;
+ }
+
+ List<String> filePaths = new ArrayList<>();
+ List<String> fileNames = new ArrayList<>();
+
+ String thisAlignment = MessageManager.getString(HMMSearch.THIS_ALIGNMENT_KEY);
+ filePaths.add(thisAlignment);
+ fileNames.add(thisAlignment);
+
+ Scanner nameScanner = new Scanner(names);
+ nameScanner.useDelimiter(Preferences.COMMA);
+
+ while (nameScanner.hasNext())
+ {
+ String next = nameScanner.next();
+ if ("null".equals(next))
+ {
+ Cache.setProperty(Preferences.HMMSEARCH_DBS, "");
+ }
+ else
+ {
+ filePaths.add(next);
+ int pos = next.lastIndexOf(File.separator);
+ String fileName = next.substring(pos + 1);
+ fileNames.add(fileName);
+ }
+ }
+ nameScanner.close();
+ ArgumentI databasesOption = new StringParameter(
+ MessageManager.getString(HMMSearch.DATABASE_KEY),
+ MessageManager.getString("label.database_for_hmmsearch"), true,
+ thisAlignment,
+ thisAlignment,
+ filePaths, fileNames);
+ args.add(databasesOption);
+ }
+
+ /**
* Answers default parameters for hmmalign, taking into account any configured
* as user preferences
*
String defseq = options.get(0);
ArgumentI arg = new StringParameter(
MessageManager.getString("label.use_hmm"), null, true, defseq,
- defseq, options);
+ defseq, options, null);
args.add(arg);
}
}
*/
if (!viewport.getAlignment().getGroups().isEmpty())
{
- Collection<String> options = new ArrayList<>();
+ List<String> options = new ArrayList<>();
options.add(MessageManager.getString("label.alignment"));
options.add(MessageManager.getString("label.groups_and_alignment"));
options.add(MessageManager.getString("label.groups"));