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.ArrayList;
import java.util.Arrays;
import java.util.Deque;
-import java.util.Enumeration;
-import java.util.Hashtable;
+import java.util.HashSet;
import java.util.List;
-import java.util.Scanner;
+import java.util.Set;
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 (new File(path).exists())
+ if (path != null && new File(path).exists())
{
IdentifyFile identifier = new IdentifyFile();
FileFormatI format = identifier.identify(path, DataSourceType.FILE);
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
MessageManager.getString("warn.invalid_format"));
}
}
- else
- {
- JOptionPane.showMessageDialog(this,
- MessageManager.getString("label.not_enough_sequences"));
- }
}
/**
- * Opens a file chooser
+ * Opens a file chooser, optionally restricted to selecting folders
+ * (directories) only. Answers the path to the selected file or folder, or
+ * null if none is chosen.
*
- * @param forFolder
+ * @param
* @return
*/
protected String openFileChooser(boolean forFolder)
{
+ // TODO duplicates GPreferences method - relocate to JalviewFileChooser?
String choice = null;
JFileChooser chooser = new JFileChooser();
if (forFolder)
alignPanel.setOverviewPanel(null);
};
});
+ if (getKeyListeners().length > 0)
+ {
+ frame.addKeyListener(getKeyListeners()[0]);
+ }
alignPanel.setOverviewPanel(overview);
}
}
if (viewport.getAlignment().getAlignmentAnnotation()
- .hashCode() != _annotationScoreVectorHash)
+ .hashCode() == _annotationScoreVectorHash)
{
- sortByAnnotScore.removeAll();
- // almost certainly a quicker way to do this - but we keep it simple
- Hashtable scoreSorts = new Hashtable();
- AlignmentAnnotation aann[];
- for (SequenceI sqa : viewport.getAlignment().getSequences())
+ return;
+ }
+
+ sortByAnnotScore.removeAll();
+ Set<String> scoreSorts = new HashSet<>();
+ for (SequenceI sqa : viewport.getAlignment().getSequences())
+ {
+ AlignmentAnnotation[] anns = sqa.getAnnotation();
+ for (int i = 0; anns != null && i < anns.length; i++)
{
- aann = sqa.getAnnotation();
- for (int i = 0; aann != null && i < aann.length; i++)
+ AlignmentAnnotation aa = anns[i];
+ if (aa != null && aa.hasScore() && aa.sequenceRef != null)
{
- if (aann[i].hasScore() && aann[i].sequenceRef != null)
- {
- scoreSorts.put(aann[i].label, aann[i].label);
- }
+ scoreSorts.add(aa.label);
}
}
- Enumeration labels = scoreSorts.keys();
- while (labels.hasMoreElements())
- {
- addSortByAnnotScoreMenuItem(sortByAnnotScore,
- (String) labels.nextElement());
- }
- sortByAnnotScore.setVisible(scoreSorts.size() > 0);
- scoreSorts.clear();
-
- _annotationScoreVectorHash = viewport.getAlignment()
- .getAlignmentAnnotation().hashCode();
}
+ for (String label : scoreSorts)
+ {
+ addSortByAnnotScoreMenuItem(sortByAnnotScore, label);
+ }
+ sortByAnnotScore.setVisible(!scoreSorts.isEmpty());
+
+ _annotationScoreVectorHash = viewport.getAlignment()
+ .getAlignmentAnnotation().hashCode();
}
/**
int assocfiles = 0;
if (filesmatched.size() > 0)
{
- if (Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false)
- || JvOptionPane.showConfirmDialog(thisaf,
- MessageManager.formatMessage(
- "label.automatically_associate_structure_files_with_sequences_same_name",
- new Object[]
- { Integer.valueOf(filesmatched.size())
- .toString() }),
- MessageManager.getString(
- "label.automatically_associate_structure_files_by_name"),
- JvOptionPane.YES_NO_OPTION) == JvOptionPane.YES_OPTION)
-
+ boolean autoAssociate = Cache.getDefault("AUTOASSOCIATE_PDBANDSEQS", false);
+ if (!autoAssociate)
+ {
+ String msg = MessageManager.formatMessage(
+ "label.automatically_associate_structure_files_with_sequences_same_name",
+ new Object[]
+ { Integer.valueOf(filesmatched.size())
+ .toString() });
+ String ttl = MessageManager.getString(
+ "label.automatically_associate_structure_files_by_name");
+ int choice = JvOptionPane.showConfirmDialog(thisaf, msg,
+ ttl, JvOptionPane.YES_NO_OPTION);
+ autoAssociate = choice == JvOptionPane.YES_OPTION;
+ }
+ if (autoAssociate)
{
for (Object[] fm : filesmatched)
{
alignPanel.paintAlignment(true, false);
}
}
+ else
+ {
+ /*
+ * add declined structures as sequences
+ */
+ for (Object[] o : filesmatched)
+ {
+ filesnotmatched.add((String) o[0]);
+ }
+ }
}
if (filesnotmatched.size() > 0)
{
}
@Override
- public void hmmerMenu_actionPerformed(ActionEvent e)
- {
- SequenceGroup grp = getViewport().getSelectionGroup();
- if (grp != null)
- {
- hmmBuild.setText(MessageManager.getString("label.hmmbuild") + " from "
- + grp.getName());
- }
- else
- {
- hmmBuild.setText(MessageManager.getString("label.hmmbuild")
- + " from Alignment");
- }
- }
-
- @Override
protected void loadVcf_actionPerformed()
{
JalviewFileChooser chooser = new JalviewFileChooser(