use of uk.ac.babraham.SeqMonk.SeqMonkException in project SeqMonk by s-andrews.
the class UpdateChecker method getLatestVersionNumber.
/**
* Gets the latest version number from the main SeqMonk site
*
* @return The version string from the remote site
* @throws SeqMonkException if the remote version couldn't be retrieved
*/
public static String getLatestVersionNumber() throws SeqMonkException {
try {
URL updateURL = new URL("http", "www.bioinformatics.babraham.ac.uk", "/projects/seqmonk/current_version.txt");
URLConnection connection = updateURL.openConnection();
connection.setUseCaches(false);
DataInputStream d = new DataInputStream(new BufferedInputStream(connection.getInputStream()));
// A version number should never be more than 255 bytes
byte[] data = new byte[255];
int bytesRead = d.read(data);
byte[] actualData = new byte[bytesRead];
for (int i = 0; i < bytesRead; i++) {
actualData[i] = data[i];
}
latestVersion = new String(actualData);
latestVersion.replaceAll("[\\r\\n]", "");
latestVersion = latestVersion.trim();
return latestVersion;
} catch (IOException e) {
e.printStackTrace();
throw new SeqMonkException("Couldn't contact the update server to check for updates");
}
}
use of uk.ac.babraham.SeqMonk.SeqMonkException in project SeqMonk by s-andrews.
the class SeqMonkMenu method actionPerformed.
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent ae) {
String action = ae.getActionCommand();
if (action.equals("exit")) {
application.dispose();
} else if (action.equals("new")) {
application.startNewProject();
} else if (action.equals("import_other")) {
JOptionPane.showMessageDialog(application, "SeqMonk can be extended to support other file formats.\n\nIf you'd like support for the format you use then please contact the program authors\nand provide them with example data files so they can write the appropriate import filters.", "Import other formats", JOptionPane.INFORMATION_MESSAGE);
} else if (action.equals("import_generic")) {
application.importData(new GenericSeqReadParser(application.dataCollection()));
} else if (action.equals("import_bed")) {
application.importData(new BedFileParser(application.dataCollection()));
} else if (action.equals("import_bedpe")) {
application.importData(new BedPEFileParser(application.dataCollection()));
} else if (action.equals("import_bowtie")) {
application.importData(new BowtieFileParser(application.dataCollection()));
} else if (action.equals("import_bismark_cov")) {
application.importData(new BismarkCovFileParser(application.dataCollection()));
} else if (action.equals("import_quasr")) {
application.importData(new QuasRFileParser(application.dataCollection()));
} else if (action.equals("import_methylkit")) {
application.importData(new MethylKitFileParser(application.dataCollection()));
} else if (action.equals("import_gff")) {
application.importData(new GffFileParser(application.dataCollection()));
} else if (action.equals("import_seqmonk")) {
application.importData(new SeqMonkReimportParser(application.dataCollection()));
} else if (action.equals("import_bam")) {
application.importData(new BAMFileParser(application.dataCollection()));
} else if (action.equals("import_visible_stores")) {
if (application.drawnDataStores() == null || application.drawnDataStores().length == 0) {
JOptionPane.showMessageDialog(application, "You need to have some data stores visible before you can use this option", "Can't reimport data", JOptionPane.ERROR_MESSAGE);
return;
}
application.importData(new VisibleStoresParser(application));
} else if (action.equals("import_active_probes")) {
if (application.dataCollection().probeSet() == null) {
JOptionPane.showMessageDialog(application, "You don't have any active probes to import at the moment", "Can't import data", JOptionPane.ERROR_MESSAGE);
return;
}
application.importData(new ActiveProbeListParser(application));
} else if (action.equals("import_hic")) {
DataStore[] drawnStores = application.drawnDataStores();
boolean foundHic = false;
for (int i = 0; i < drawnStores.length; i++) {
if (drawnStores[i] instanceof HiCDataStore && ((HiCDataStore) drawnStores[i]).isValidHiC()) {
foundHic = true;
}
}
if (!foundHic) {
JOptionPane.showMessageDialog(application, "You need to have at least one visible HiC data set to use this option", "Can't import HiC data", JOptionPane.ERROR_MESSAGE);
return;
}
application.importData(new HiCOtherEndExtractor(application.dataCollection(), application.drawnDataStores()));
} else if (action.equals("annot_gff")) {
AnnotationParserRunner.RunAnnotationParser(application, new GFF3AnnotationParser(application.dataCollection().genome()));
} else if (action.equals("annot_generic")) {
AnnotationParserRunner.RunAnnotationParser(application, new GenericAnnotationParser(application.dataCollection().genome()));
} else if (action.equals("annot_probe")) {
if (application.dataCollection().probeSet() == null) {
JOptionPane.showMessageDialog(application, "You haven't made a probeset yet (Do Data > Quantitation > Define Probes)", "Can't make new annotation", JOptionPane.ERROR_MESSAGE);
return;
}
String featureType = null;
while (true) {
featureType = (String) JOptionPane.showInputDialog(application, "Enter new feature type", "Set feature type", JOptionPane.QUESTION_MESSAGE, null, null, application.dataCollection().probeSet().getActiveList().name());
if (featureType == null)
// They cancelled
return;
if (featureType.length() == 0)
// Try again
continue;
break;
}
AnnotationParserRunner.RunAnnotationParser(application, new ProbeListAnnotationParser(application.dataCollection().genome(), application.dataCollection().probeSet().getActiveList(), featureType));
} else if (action.equals("about")) {
new AboutDialog();
} else if (action.equals("help_license")) {
try {
new LicenseDialog(application);
} catch (IOException e) {
e.printStackTrace();
}
} else if (action.equals("help_contents")) {
try {
// Java has a bug in it which affects the creation of valid URIs from
// URLs relating to an windows UNC path. We therefore have to mung
// URLs starting file file:// to add 5 forward slashes so that we
// end up with a valid URI.
URL url = ClassLoader.getSystemResource("Help");
if (url.toString().startsWith("file://")) {
try {
url = new URL(url.toString().replace("file://", "file://///"));
} catch (MalformedURLException e) {
throw new IllegalStateException(e);
}
}
new HelpDialog(new File(url.toURI()));
} catch (URISyntaxException ux) {
System.err.println("Couldn't parse URL falling back to path");
new HelpDialog(new File(ClassLoader.getSystemResource("Help").getPath()));
}
} else if (action.equals("zoom_in")) {
application.chromosomeViewer().zoomIn();
} else if (action.equals("zoom_out")) {
application.chromosomeViewer().zoomOut();
} else if (action.equals("move_left")) {
application.chromosomeViewer().moveLeft();
} else if (action.equals("move_right")) {
application.chromosomeViewer().moveRight();
} else if (action.equals("page_left")) {
application.chromosomeViewer().pageLeft();
} else if (action.equals("page_right")) {
application.chromosomeViewer().pageRight();
} else if (action.equals("view_display_options")) {
new DisplayPreferencesEditorDialog();
} else if (action.equals("data_reads_probes")) {
DisplayPreferences.getInstance().setDisplayMode(DisplayPreferences.DISPLAY_MODE_READS_AND_QUANTITATION);
} else if (action.equals("data_reads")) {
DisplayPreferences.getInstance().setDisplayMode(DisplayPreferences.DISPLAY_MODE_READS_ONLY);
} else if (action.equals("data_probes")) {
DisplayPreferences.getInstance().setDisplayMode(DisplayPreferences.DISPLAY_MODE_QUANTITATION_ONLY);
} else if (action.equals("read_density_low")) {
DisplayPreferences.getInstance().setReadDensity(DisplayPreferences.READ_DENSITY_LOW);
} else if (action.equals("read_density_medium")) {
DisplayPreferences.getInstance().setReadDensity(DisplayPreferences.READ_DENSITY_MEDIUM);
} else if (action.equals("read_density_high")) {
DisplayPreferences.getInstance().setReadDensity(DisplayPreferences.READ_DENSITY_HIGH);
} else if (action.equals("read_pack_combine")) {
DisplayPreferences.getInstance().setReadDisplay(DisplayPreferences.READ_DISPLAY_COMBINED);
} else if (action.equals("read_pack_separate")) {
DisplayPreferences.getInstance().setReadDisplay(DisplayPreferences.READ_DISPLAY_SEPARATED);
} else if (action.equals("data_colour_dynamic")) {
DisplayPreferences.getInstance().setColourType(DisplayPreferences.COLOUR_TYPE_GRADIENT);
} else if (action.equals("data_colour_fixed")) {
DisplayPreferences.getInstance().setColourType(DisplayPreferences.COLOUR_TYPE_INDEXED);
} else if (action.equals("scale_positive")) {
DisplayPreferences.getInstance().setScaleType(DisplayPreferences.SCALE_TYPE_POSITIVE);
} else if (action.equals("scale_negative")) {
DisplayPreferences.getInstance().setScaleType(DisplayPreferences.SCALE_TYPE_POSITIVE_AND_NEGATIVE);
} else if (action.equals("view_annotation_tracks")) {
new AnnotationTrackSelector(application);
} else if (action.equals("view_data_tracks")) {
new DataTrackSelector(application);
} else if (action.equals("view_boxwhisker")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new MultiBoxWhiskerDialog(application.drawnDataSets(), new ProbeList[] { application.dataCollection().probeSet().getActiveList() });
}
} else if (action.equals("view_starwars")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new MultiStarWarsDialog(application.drawnDataSets(), new ProbeList[] { application.dataCollection().probeSet().getActiveList() });
}
} else if (action.equals("view_beanplot")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new MultiBeanPlotDialog(application.drawnDataSets(), new ProbeList[] { application.dataCollection().probeSet().getActiveList() });
}
} else if (action.equals("view_cumdist")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
try {
new CumulativeDistributionDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
}
} else if (action.equals("view_qqdist")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
try {
new QQDistributionDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
}
} else if (action.equals("plot_rna_qc")) {
new RNAQCPreferencesDialog(application.dataCollection(), application.drawnDataSets());
} else if (action.equals("plot_small_rna_qc")) {
new SmallRNAQCPreferencesDialog(application.dataCollection());
} else if (action.startsWith("toolbar_")) {
// We're toggling the visibility of one of the toolbars;
int index = Integer.parseInt(action.replaceAll("toolbar_", ""));
toolbars[index].setShown(!toolbars[index].shown());
updateVisibleToolBars();
} else if (action.startsWith("multiprobe")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
return;
}
ProbeList[] probeLists = ProbeListSelectorDialog.selectProbeLists();
if (probeLists == null || probeLists.length == 0)
return;
else if (action.equals("multiprobe_view_boxwhisker")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
return;
}
new MultiBoxWhiskerDialog(new DataStore[] { application.dataCollection().getActiveDataStore() }, probeLists);
} else if (action.equals("multiprobe_view_beanplot")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
return;
}
new MultiBeanPlotDialog(new DataStore[] { application.dataCollection().getActiveDataStore() }, probeLists);
} else if (action.equals("multiprobe_view_starwars")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
return;
}
new MultiStarWarsDialog(new DataStore[] { application.dataCollection().getActiveDataStore() }, probeLists);
} else if (action.equals("multiprobe_view_multistore_boxwhisker")) {
new MultiBoxWhiskerDialog(application.drawnDataSets(), probeLists);
} else if (action.equals("multiprobe_view_multistore_beanplot")) {
new MultiBeanPlotDialog(application.drawnDataSets(), probeLists);
} else if (action.equals("multiprobe_view_multistore_starwars")) {
new MultiStarWarsDialog(application.drawnDataSets(), probeLists);
} else if (action.equals("multiprobe_view_probetrend")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new TrendOverProbePreferencesDialog(probeLists, application.drawnDataSets());
}
} else if (action.equals("multiprobe_view_cumdist")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
return;
}
try {
new CumulativeDistributionDialog(application.dataCollection().getActiveDataStore(), probeLists);
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
} else if (action.equals("multiprobe_view_qqdist")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store from the data panel to use this view", "No active data store", JOptionPane.INFORMATION_MESSAGE);
return;
}
try {
new QQDistributionDialog(application.dataCollection().getActiveDataStore(), probeLists);
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
} else if (action.equals("multiprobe_view_line_graph")) {
try {
new LineGraphDialog(application.drawnDataSets(), probeLists);
} catch (SeqMonkException sme) {
JOptionPane.showMessageDialog(application, sme.getLocalizedMessage(), "Can't draw graph", JOptionPane.ERROR_MESSAGE);
}
} else if (action.equals("multiprobe_view_heatmap_active")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select an active data store to view this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
} else if (!(application.dataCollection().getActiveDataStore() instanceof HiCDataStore && ((HiCDataStore) application.dataCollection().getActiveDataStore()).isValidHiC())) {
JOptionPane.showMessageDialog(application, "Your active data store needs to be a HiC dataset to view this plot", "Wrong data selected...", JOptionPane.INFORMATION_MESSAGE);
} else {
new HeatmapProbeListWindow((HiCDataStore) application.dataCollection().getActiveDataStore(), probeLists, application.dataCollection().genome());
}
} else if (action.equals("multiprobe_plot_list_overlap")) {
new ListOverlapsDialog(probeLists);
} else if (action.equals("multiprobe_list_giraph_plot")) {
if (probeLists.length > 50) {
JOptionPane.showMessageDialog(application, "Please select fewer than 50 probe lists to display", "Too many probe lists...", JOptionPane.INFORMATION_MESSAGE);
} else {
new GiraphPlot(probeLists);
}
}
} else if (action.equals("view_value_histogram")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store in the Data panel before viewing this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
} else {
if (!application.dataCollection().getActiveDataStore().isQuantitated()) {
JOptionPane.showMessageDialog(application, "Your active data store hasn't been quantitated yet", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
try {
new ProbeValueHistogramPlot(application.dataCollection().getActiveDataStore(), application.dataCollection().probeSet().getActiveList());
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
}
}
} else if (action.equals("plot_duplication")) {
if (application.dataCollection().probeSet() == null) {
JOptionPane.showMessageDialog(application, "You need to make some probes before running this plot", "No probes...", JOptionPane.INFORMATION_MESSAGE);
} else {
new DuplicationPlotDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
}
} else if (action.equals("view_read_length_histogram")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store in the Data panel before viewing this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
} else {
new ReadLengthHistogramPlot(application.dataCollection().getActiveDataStore());
}
} else if (action.startsWith("view_hic_length_")) {
if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select a data store in the Data panel before viewing this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
} else if (!(application.dataCollection().getActiveDataStore() instanceof HiCDataStore && ((HiCDataStore) application.dataCollection().getActiveDataStore()).isValidHiC())) {
JOptionPane.showMessageDialog(application, "This plot can only be used on HiC data stores", "Not HiC data...", JOptionPane.INFORMATION_MESSAGE);
} else {
if (action.equals("view_hic_length_histogram")) {
new HiCLengthHistogramPlot((HiCDataStore) application.dataCollection().getActiveDataStore(), null);
} else if (action.equals("view_hic_length_probes")) {
if (application.dataCollection().probeSet() != null) {
new HiCLengthHistogramPlot((HiCDataStore) application.dataCollection().getActiveDataStore(), application.dataCollection().probeSet().getActiveList());
} else {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data before selecting this option", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
}
}
}
} else if (action.equals("cis_trans_scatterplot")) {
// Check to see if we have any HiC datasets
DataStore[] stores = application.dataCollection().getAllDataStores();
boolean foundHiC = false;
for (int s = 0; s < stores.length; s++) {
if (stores[s] instanceof HiCDataStore && ((HiCDataStore) stores[s]).isValidHiC()) {
foundHiC = true;
break;
}
}
if (!foundHiC) {
JOptionPane.showMessageDialog(application, "You don't appear to have any HiC data to plot", "No data available...", JOptionPane.INFORMATION_MESSAGE);
return;
}
new CisTransScatterPlotDialog(application.dataCollection());
} else if (action.equals("view_probe_length_histogram")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new ProbeLengthHistogramPlot(application.dataCollection().probeSet().getActiveList());
}
} else if (action.equals("view_probetrend")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new TrendOverProbePreferencesDialog(new ProbeList[] { application.dataCollection().probeSet().getActiveList() }, application.drawnDataSets());
}
} else if (action.equals("view_quanttrend")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new QuantiationTrendPlotPreferencesDialog(application.dataCollection(), application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
}
} else // }
if (action.equals("view_aligned_probes")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new AlignedSummaryPreferencesDialog(new ProbeList[] { application.dataCollection().probeSet().getActiveList() }, application.drawnDataSets());
}
} else if (action.equals("view_aligned_probes_multi")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
ProbeList[] probeLists = ProbeListSelectorDialog.selectProbeLists();
if (probeLists == null || probeLists.length == 0)
return;
new AlignedSummaryPreferencesDialog(probeLists, application.drawnDataSets());
}
} else if (action.equals("view_heatmap_active")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else if (application.dataCollection().getActiveDataStore() == null) {
JOptionPane.showMessageDialog(application, "You need to select an active data store to view this plot", "No data selected...", JOptionPane.INFORMATION_MESSAGE);
} else if (!(application.dataCollection().getActiveDataStore() instanceof HiCDataStore && ((HiCDataStore) application.dataCollection().getActiveDataStore()).isValidHiC())) {
JOptionPane.showMessageDialog(application, "Your active data store needs to be a HiC dataset to view this plot", "Wrong data selected...", JOptionPane.INFORMATION_MESSAGE);
} else {
new HeatmapGenomeWindow((HiCDataStore) application.dataCollection().getActiveDataStore(), application.dataCollection().probeSet().getActiveList(), application.dataCollection().genome());
}
} else if (action.equals("plot_domainogram")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new DomainogramPreferencesDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
}
} else if (action.equals("view_variance_plot")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else if (application.dataCollection().getAllReplicateSets().length == 0) {
JOptionPane.showMessageDialog(application, "This plot only works on Replicate Sets and you don't have any", "No replicate sets...", JOptionPane.INFORMATION_MESSAGE);
} else {
new VariancePlotDialog(application.dataCollection());
}
} else if (action.equals("view_strand_bias_plot")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new StrandBiasPlotDialog(application.dataCollection());
}
} else if (action.equals("view_scatterplot")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new ScatterPlotDialog(application.dataCollection());
}
} else if (action.equals("view_ma_plot")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new MAPlotDialog(application.dataCollection());
}
} else if (action.equals("view_line_graph")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
try {
new LineGraphDialog(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
} catch (SeqMonkException sme) {
JOptionPane.showMessageDialog(application, sme.getLocalizedMessage(), "Can't draw graph", JOptionPane.ERROR_MESSAGE);
}
}
} else if (action.equals("view_datastore_tree")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new DataStoreTreeDialog(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
}
} else if (action.equals("view_pca")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new PCADataCalculator(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
}
} else if (action.equals("view_tsne")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new TsneOptionsDialog(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets());
}
} else if (action.equals("view_correlation_matrix")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
new CorrelationMatrix(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
}
} else if (action.startsWith("view_hierarchical_cluster")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data to view this plot", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
} else {
boolean normalise = false;
if (action.endsWith("normalised")) {
normalise = true;
}
new HierarchicalClusterDialog(application.dataCollection().probeSet().getActiveList(), application.drawnDataSets(), normalise);
}
} else if (action.equals("view_all_labels")) {
application.chromosomeViewer().toggleLabels();
} else if (action.equals("view_set_zoom")) {
new DataZoomSelector(application);
} else if (action.equals("define_probes")) {
new DefineProbeOptions(application);
} else if (action.equals("quantitation")) {
if (application.dataCollection().probeSet() == null) {
JOptionPane.showMessageDialog(application, "You need to define some probes before quantitating", "No probes...", JOptionPane.INFORMATION_MESSAGE);
new DefineProbeOptions(application);
} else {
new DefineQuantitationOptions(application);
}
} else if (action.equals("pipeline_quantitation")) {
new DefinePipelineOptions(application);
} else if (action.equals("edit_groups")) {
new GroupEditor(application);
} else if (action.equals("edit_replicates")) {
new ReplicateSetEditor(application);
} else if (action.equals("auto_create_groups")) {
new AutoSplitDataDialog(application);
} else if (action.equals("edit_samples")) {
new DataSetEditor(application.dataCollection());
} else if (action.equals("save")) {
application.saveProject();
} else if (action.equals("save_as")) {
application.saveProjectAs();
} else if (action.equals("file_export_chromosome_view")) {
// We don't want the scroll bars to appear in the drawn image
// so we temporarily remove them.
// application.chromosomeViewer().scrollPane().setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
// application.chromosomeViewer().scrollPane().validate();
ImageSaver.saveImage(application.chromosomeViewer());
// application.chromosomeViewer().scrollPane().setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// application.chromosomeViewer().scrollPane().validate();
} else if (action.equals("file_export_genome_view")) {
ImageSaver.saveImage(application.genomeViewer());
} else if (action.equals("file_export_bedgraph")) {
if (!application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You need to have quantitated your data", "No quantitation...", JOptionPane.INFORMATION_MESSAGE);
return;
}
BedGraphDataWriter bgw = new BedGraphDataWriter(application.drawnDataSets(), application.dataCollection().probeSet().getActiveList());
bgw.startProcessing();
} else if (action.equals("open")) {
application.loadProject();
} else if (action.equals("open_switch")) {
application.loadProjectAndSwitchAssembly();
} else if (action.startsWith("filter")) {
try {
if (action.startsWith("filter_r_")) {
try {
RVersionTest.testRVersion(SeqMonkPreferences.getInstance().RLocation());
} catch (IOException ioe) {
JOptionPane.showMessageDialog(application, "<html>Can't find R at '" + SeqMonkPreferences.getInstance().RLocation() + "'<br><br>Please set the path to R under Edit > Preferences > Programs", "Can't find R", JOptionPane.ERROR_MESSAGE);
return;
}
if (action.equals("filter_r_deseq2")) {
new FilterOptionsDialog(application.dataCollection(), new DESeqFilter(application.dataCollection()));
} else if (action.equals("filter_r_limma")) {
new FilterOptionsDialog(application.dataCollection(), new LimmaFilter(application.dataCollection()));
} else if (action.equals("filter_r_edger")) {
new FilterOptionsDialog(application.dataCollection(), new EdgeRFilter(application.dataCollection()));
} else if (action.equals("filter_r_edger_forrev")) {
new FilterOptionsDialog(application.dataCollection(), new EdgeRForRevFilter(application.dataCollection()));
} else if (action.equals("filter_r_logistic_regression")) {
new FilterOptionsDialog(application.dataCollection(), new LogisticRegressionFilter(application.dataCollection()));
} else if (action.equals("filter_r_logistic_regression_splicing")) {
new FilterOptionsDialog(application.dataCollection(), new LogisticRegressionSplicingFilter(application.dataCollection()));
} else {
throw new IllegalArgumentException("Didn't understand command '" + action + "'");
}
} else if (action.equals("filter_values_individual")) {
new FilterOptionsDialog(application.dataCollection(), new ValuesFilter(application.dataCollection()));
} else if (action.equals("filter_values_windowed")) {
new FilterOptionsDialog(application.dataCollection(), new WindowedValuesFilter(application.dataCollection()));
} else if (action.equals("filter_values_distribution")) {
new FilterOptionsDialog(application.dataCollection(), new DistributionPositionFilter(application.dataCollection()));
} else if (action.equals("filter_diffs_individual")) {
new FilterOptionsDialog(application.dataCollection(), new DifferencesFilter(application.dataCollection()));
} else if (action.equals("filter_diffs_windowed")) {
new FilterOptionsDialog(application.dataCollection(), new WindowedDifferencesFilter(application.dataCollection()));
} else if (action.equals("filter_var_individual")) {
new FilterOptionsDialog(application.dataCollection(), new VarianceValuesFilter(application.dataCollection()));
} else if (action.equals("filter_intensity_stats")) {
new FilterOptionsDialog(application.dataCollection(), new IntensityDifferenceFilter(application.dataCollection()));
} else if (action.equals("filter_intensity_var_stats")) {
new FilterOptionsDialog(application.dataCollection(), new VarianceIntensityDifferenceFilter(application.dataCollection()));
} else if (action.equals("filter_proportion_library")) {
new FilterOptionsDialog(application.dataCollection(), new ProportionOfLibraryStatisticsFilter(application.dataCollection()));
} else if (action.equals("filter_intensity_replicate_stats")) {
new FilterOptionsDialog(application.dataCollection(), new IntensityReplicateFilter(application.dataCollection()));
} else if (action.equals("filter_statsr")) {
new FilterOptionsDialog(application.dataCollection(), new WindowedReplicateStatsFilter(application.dataCollection()));
} else if (action.equals("filter_stats")) {
new FilterOptionsDialog(application.dataCollection(), new ReplicateSetStatsFilter(application.dataCollection()));
} else if (action.equals("filter_monte_carlo")) {
new FilterOptionsDialog(application.dataCollection(), new MonteCarloFilter(application.dataCollection()));
} else // Laura
if (action.equals("filter_genesets")) {
new FilterOptionsDialog(application.dataCollection(), new GeneSetIntensityDifferenceFilter(application.dataCollection()));
} else if (action.equals("filter_boxwhisker")) {
BoxWhiskerFilter filter = new BoxWhiskerFilter(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_chisquare_stores")) {
ChiSquareFilter filter = new ChiSquareFilter(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_chisquare_forrev")) {
ChiSquareFilterForRev filter = new ChiSquareFilterForRev(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_chisquare_frontback")) {
ChiSquareFilterFrontBack filter = new ChiSquareFilterFrontBack(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_binomial_forrev")) {
BinomialFilterForRev filter = new BinomialFilterForRev(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_correlation_cluster")) {
CorrelationClusterFilter filter = new CorrelationClusterFilter(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_correlation_probes")) {
CorrelationFilter filter = new CorrelationFilter(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_correlation_manual")) {
ManualCorrelationFilter filter = new ManualCorrelationFilter(application.dataCollection());
new FilterOptionsDialog(application.dataCollection(), filter);
} else if (action.equals("filter_position")) {
new FilterOptionsDialog(application.dataCollection(), new PositionFilter(application.dataCollection(), DisplayPreferences.getInstance().getCurrentChromosome(), SequenceRead.start(DisplayPreferences.getInstance().getCurrentLocation()), SequenceRead.end(DisplayPreferences.getInstance().getCurrentLocation())));
} else // }
if (action.equals("filter_length")) {
new FilterOptionsDialog(application.dataCollection(), new ProbeLengthFilter(application.dataCollection()));
} else if (action.equals("filter_features")) {
new FilterOptionsDialog(application.dataCollection(), new FeatureFilter(application.dataCollection()));
} else if (action.equals("filter_feature_names")) {
new FilterOptionsDialog(application.dataCollection(), new FeatureNameFilter(application.dataCollection()));
} else if (action.equals("filter_probe_names")) {
new FilterOptionsDialog(application.dataCollection(), new ProbeNameFilter(application.dataCollection()));
} else if (action.equals("filter_deduplication")) {
new FilterOptionsDialog(application.dataCollection(), new DeduplicationFilter(application.dataCollection()));
} else if (action.equals("filter_random")) {
new FilterOptionsDialog(application.dataCollection(), new RandomFilter(application.dataCollection()));
} else if (action.equals("filter_combine")) {
new FilterOptionsDialog(application.dataCollection(), new CombineFilter(application.dataCollection()));
} else if (action.equals("filter_collate")) {
new FilterOptionsDialog(application.dataCollection(), new CollateListsFilter(application.dataCollection()));
}
} catch (SeqMonkException e) {
JOptionPane.showMessageDialog(application, e.getMessage(), "Can't run filter", JOptionPane.ERROR_MESSAGE);
}
} else if (action.startsWith("report")) {
if (action != "report_summary" && !application.dataCollection().isQuantitated()) {
JOptionPane.showMessageDialog(application, "You must quantiate your data before creating reports", "Can't generate report", JOptionPane.ERROR_MESSAGE);
return;
}
if (action.equals("report_annotated")) {
new ReportOptions(application, new AnnotatedListReport(application.dataCollection(), application.drawnDataSets()));
} else if (action.equals("report_description")) {
new ProbeListReportCreator(application.dataCollection().probeSet().getActiveList());
} else if (action.equals("report_group")) {
new ReportOptions(application, new ProbeGroupReport(application.dataCollection(), application.drawnDataSets()));
} else if (action.equals("report_feature")) {
new ReportOptions(application, new FeatureReport(application.dataCollection(), application.drawnDataSets()));
} else if (action.equals("report_summary")) {
new ReportOptions(application, new DataStoreSummaryReport(application.dataCollection(), application.drawnDataSets()));
} else if (action.equals("report_chromosome")) {
new ReportOptions(application, new ChromosomeViewReport(application.dataCollection(), application.drawnDataSets()));
}
} else if (action.equals("edit_preferences")) {
new EditPreferencesDialog(application.dataCollection());
} else if (action.equals("find_feature")) {
new FindFeatureDialog(application.dataCollection());
} else if (action.equals("find_feature_names")) {
new FindFeaturesByNameDialog(application.dataCollection());
} else if (action.equals("goto_position")) {
new GotoDialog(application);
} else if (action.equals("goto_window")) {
new GotoWindowDialog(application);
} else if (action.equals("copy_position")) {
Clipboard c = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable t = new StringSelection("chr" + DisplayPreferences.getInstance().getCurrentChromosome().name() + ":" + SequenceRead.start(DisplayPreferences.getInstance().getCurrentLocation()) + "-" + SequenceRead.end(DisplayPreferences.getInstance().getCurrentLocation()));
c.setContents(t, null);
} else {
throw new IllegalStateException("Unknown command '" + action + "' from main menu");
}
}
use of uk.ac.babraham.SeqMonk.SeqMonkException in project SeqMonk by s-andrews.
the class BoxWhiskerFilter method generateProbeList.
/* (non-Javadoc)
* @see uk.ac.babraham.SeqMonk.Filters.ProbeFilter#generateProbeList()
*/
protected void generateProbeList() {
ProbeList newList = new ProbeList(startingList, "Filtered Probes", "", null);
Hashtable<Probe, Integer> hitCounts = new Hashtable<Probe, Integer>();
for (int s = 0; s < stores.length; s++) {
progressUpdated("Processing " + stores[s].name(), s, stores.length);
if (cancel) {
cancel = false;
progressCancelled();
return;
}
BoxWhisker bw;
try {
bw = new BoxWhisker(stores[s], startingList, stringency);
} catch (SeqMonkException e) {
System.err.println("Ignoring unquantitated dataset");
e.printStackTrace();
continue;
}
if (useUpper) {
Probe[] p = bw.upperProbeOutliers();
if (cancel) {
cancel = false;
progressCancelled();
return;
}
for (int i = 0; i < p.length; i++) {
if (hitCounts.containsKey(p[i])) {
hitCounts.put(p[i], hitCounts.get(p[i]).intValue() + 1);
} else {
hitCounts.put(p[i], 1);
}
}
}
if (useLower) {
Probe[] p = bw.lowerProbeOutliers();
for (int i = 0; i < p.length; i++) {
if (cancel) {
cancel = false;
progressCancelled();
return;
}
if (hitCounts.containsKey(p[i])) {
hitCounts.put(p[i], hitCounts.get(p[i]).intValue() + 1);
} else {
hitCounts.put(p[i], 1);
}
}
}
}
// Now we can go through the probes which hit and see if
// we had enough hits to put them into our final list.
Enumeration<Probe> candidates = hitCounts.keys();
while (candidates.hasMoreElements()) {
if (cancel) {
cancel = false;
progressCancelled();
return;
}
Probe candidate = candidates.nextElement();
int count = hitCounts.get(candidate).intValue();
// probe to the probe set.
switch(filterType) {
case EXACTLY:
if (count == storeCutoff)
newList.addProbe(candidate, null);
break;
case AT_LEAST:
if (count >= storeCutoff)
newList.addProbe(candidate, null);
break;
case NO_MORE_THAN:
if (count <= storeCutoff)
newList.addProbe(candidate, null);
break;
}
}
filterFinished(newList);
}
use of uk.ac.babraham.SeqMonk.SeqMonkException in project SeqMonk by s-andrews.
the class VariancePlotPanel method calculateNonredundantSet.
/**
* This collapses individual points which are over the same
* pixel when redrawing the plot at a different scale
*/
private synchronized void calculateNonredundantSet() {
closestPoint = null;
ProbePairValue[][] grid = new ProbePairValue[getWidth()][getHeight()];
Probe[] probes = probeList.getAllProbes();
try {
for (int p = 0; p < probes.length; p++) {
float xValue = repSet.getValueForProbeExcludingUnmeasured(probes[p]);
float yValue = getYValue(probes[p]);
if (Float.isNaN(xValue) || Float.isInfinite(xValue) || Float.isNaN(yValue) || Float.isInfinite(yValue)) {
continue;
}
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
grid[x][y] = new ProbePairValue(xValue, yValue, x, y);
grid[x][y].setProbe(probes[p]);
} else {
// belong to
if (subLists == null)
grid[x][y].count++;
// As we have multiple probes at this point we remove the
// specific probe annotation.
grid[x][y].setProbe(null);
}
}
if (subLists != null) {
for (int s = 0; s < subLists.length; s++) {
Probe[] subListProbes = subLists[s].getAllProbes();
for (int p = 0; p < subListProbes.length; p++) {
float xValue = repSet.getValueForProbeExcludingUnmeasured(subListProbes[p]);
float yValue = getYValue(subListProbes[p]);
int x = getX(xValue);
int y = getY(yValue);
if (grid[x][y] == null) {
// This messes up where we catch it in the middle of a redraw
continue;
// throw new IllegalArgumentException("Found subList position not in main list");
}
// 1 = no list so 2 is the lowest sublist index
grid[x][y].count = s + 2;
}
}
}
} catch (SeqMonkException e) {
throw new IllegalStateException(e);
}
// Now we need to put all of the ProbePairValues into
// a single array;
int count = 0;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null)
count++;
}
}
ProbePairValue[] nonred = new ProbePairValue[count];
count--;
for (int x = 0; x < grid.length; x++) {
for (int y = 0; y < grid[x].length; y++) {
if (grid[x][y] != null) {
nonred[count] = grid[x][y];
count--;
}
}
}
Arrays.sort(nonred);
// Work out the 95% percentile count
int minCount = 1;
int maxCount = 2;
if (nonred.length > 0) {
minCount = nonred[0].count;
maxCount = nonred[((nonred.length - 1) * 95) / 100].count;
}
// Go through every nonred assigning a suitable colour
ColourGradient gradient = new HotColdColourGradient();
for (int i = 0; i < nonred.length; i++) {
if (subLists == null) {
nonred[i].color = gradient.getColor(nonred[i].count, minCount, maxCount);
} else {
if (nonred[i].count > subLists.length + 1) {
throw new IllegalArgumentException("Count above threshold when showing sublists");
}
if (nonred[i].count == 1) {
nonred[i].color = VERY_LIGHT_GREY;
} else {
nonred[i].color = ColourIndexSet.getColour(nonred[i].count - 2);
}
}
}
nonRedundantValues = nonred;
lastNonredWidth = getWidth();
lastNonredHeight = getHeight();
// System.out.println("Nonred was "+nonRedundantValues.length+" from "+probes.length);
}
use of uk.ac.babraham.SeqMonk.SeqMonkException in project SeqMonk by s-andrews.
the class SeqMonkInformationPanel method run.
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run() {
// Check for an available update to the SeqMonk Program
try {
if (UpdateChecker.isUpdateAvailable()) {
String latestVersion = UpdateChecker.getLatestVersionNumber();
programUpdateLabel.setIcon(warningIcon);
programUpdateLabelText.setText("A newer version of SeqMonk (v" + latestVersion + ") is available");
} else {
if (SeqMonkApplication.VERSION.contains("devel")) {
programUpdateLabel.setIcon(warningIcon);
programUpdateLabelText.setText("You are running a current development version of SeqMonk");
} else {
programUpdateLabel.setIcon(tickIcon);
programUpdateLabelText.setText("You are running the latest version of SeqMonk");
}
}
} catch (SeqMonkException e) {
programUpdateLabel.setIcon(errorIcon);
programUpdateLabelText.setText("Failed to check for SeqMonk updates");
e.printStackTrace();
}
// Check for an available update to any of the installed genomes
try {
DownloadableGenomeSet availableGenomes = new DownloadableGenomeSet();
updates = availableGenomes.findUpdateableGenomes();
if (updates != null && updates.length > 0) {
genomeUpdateLabel.setIcon(warningIcon);
genomeUpdateLabelText.setText("There are updates available for " + updates.length + " of your installed genomes");
updateGenomesButton.setVisible(true);
} else {
genomeUpdateLabel.setIcon(tickIcon);
genomeUpdateLabelText.setText("All of your installed genomes are up to date");
}
} catch (Exception e) {
genomeUpdateLabel.setIcon(errorIcon);
genomeUpdateLabelText.setText("Failed to check for genome updates");
e.printStackTrace();
}
try {
String rVersion = RVersionTest.testRVersion(SeqMonkPreferences.getInstance().RLocation());
if (rVersion.startsWith("2") || rVersion.startsWith("3.0")) {
// They're going to have a problem, so let's not encourage this
rLabel.setIcon(warningIcon);
rLabelText.setText("Found R version " + rVersion + " but this is too old to use. Please update to the latest R");
setRLocationButton.setVisible(true);
return;
}
if (!RVersionTest.hasRDependencies()) {
rLabel.setIcon(warningIcon);
rLabelText.setText("Found a valid R installation, but package dependencies were missing");
installRDependenciesButton.setVisible(true);
} else {
rLabel.setIcon(tickIcon);
rLabelText.setText("Found valid R version (" + rVersion + ") at '" + SeqMonkPreferences.getInstance().RLocation() + "'");
}
} catch (IOException ioe) {
if (SeqMonkPreferences.getInstance().RLocation().equals("R")) {
rLabel.setIcon(infoIcon);
rLabelText.setText("Couldn't find a valid default R installation " + ioe.getMessage());
setRLocationButton.setVisible(true);
} else {
rLabel.setIcon(errorIcon);
rLabelText.setText("Couldn't find a valid R installation at " + SeqMonkPreferences.getInstance().RLocation() + " " + ioe.getMessage());
setRLocationButton.setVisible(true);
}
}
}
Aggregations