Search in sources :

Example 1 with HiCDataStore

use of uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore in project SeqMonk by s-andrews.

the class VisibleStoresParser method processHiCDataStore.

private DataSet processHiCDataStore(DataStore store) throws SeqMonkException {
    int extendBy = prefs.extendReads();
    boolean reverse = prefs.reverseReads();
    boolean removeStrand = prefs.removeStrandInfo();
    PairedDataSet newData = new PairedDataSet(store.name() + "_reimport", "Reimported from " + store.name(), prefs.removeDuplicates(), prefs.hiCDistance(), prefs.hiCIgnoreTrans());
    // Now process the data
    Chromosome[] chrs = dataCollection().genome().getAllChromosomes();
    for (int c = 0; c < chrs.length; c++) {
        progressUpdated("Processing " + store.name() + " chr " + chrs[c].name(), c, chrs.length);
        // We make the call to get exportable reads so we don't duplicate reads
        // when we export things
        HiCHitCollection hitCollection = ((HiCDataStore) store).getExportableReadsForChromosome(chrs[c]);
        String[] localChromosomes = hitCollection.getChromosomeNamesWithHits();
        for (int c2 = 0; c2 < localChromosomes.length; c2++) {
            Chromosome localChromosome = SeqMonkApplication.getInstance().dataCollection().genome().getChromosome(localChromosomes[c2]).chromosome();
            long[] sourceReads = hitCollection.getSourcePositionsForChromosome(localChromosomes[c2]);
            long[] hitReads = hitCollection.getHitPositionsForChromosome(localChromosomes[c2]);
            for (int r = 0; r < sourceReads.length; r++) {
                if (cancel) {
                    progressCancelled();
                    return null;
                }
                if (downsample && downsampleProbabilty < 1) {
                    if (Math.random() > downsampleProbabilty) {
                        continue;
                    }
                }
                if ((!(reverse || removeStrand)) && extendBy == 0 && (!filterByFeature)) {
                    // Just add them as they are
                    newData.addData(chrs[c], sourceReads[r]);
                    newData.addData(localChromosome, hitReads[r]);
                }
                Feature[] features = null;
                if (filterByFeature) {
                    features = collection.genome().annotationCollection().getFeaturesForType(chrs[c], featureType);
                    Arrays.sort(features);
                }
                int currentFeaturePostion = 0;
                if (filterByFeature) {
                    // See if we're comparing against the right feature
                    while (SequenceRead.start(sourceReads[r]) > features[currentFeaturePostion].location().end() && currentFeaturePostion < (features.length - 1)) {
                        currentFeaturePostion++;
                    }
                    // Test to see if we overlap
                    if (SequenceRead.overlaps(sourceReads[r], features[currentFeaturePostion].location().packedPosition())) {
                        if (excludeFeature)
                            continue;
                    } else {
                        if (!excludeFeature)
                            continue;
                    }
                }
                int sourceStart = SequenceRead.start(sourceReads[r]);
                int sourceEend = SequenceRead.end(sourceReads[r]);
                int sourceStrand = SequenceRead.strand(sourceReads[r]);
                int hitStart = SequenceRead.start(sourceReads[r]);
                int hitEend = SequenceRead.end(hitReads[r]);
                int hitStrand = SequenceRead.strand(hitReads[r]);
                if (reverse) {
                    if (sourceStrand == Location.FORWARD) {
                        sourceStrand = Location.REVERSE;
                    } else if (sourceStrand == Location.REVERSE) {
                        sourceStrand = Location.FORWARD;
                    }
                    if (hitStrand == Location.FORWARD) {
                        hitStrand = Location.REVERSE;
                    } else if (hitStrand == Location.REVERSE) {
                        hitStrand = Location.FORWARD;
                    }
                }
                if (removeStrand) {
                    sourceStrand = Location.UNKNOWN;
                    hitStrand = Location.UNKNOWN;
                }
                if (extendBy > 0) {
                    if (sourceStrand == Location.FORWARD) {
                        sourceEend += extendBy;
                    } else if (sourceStrand == Location.REVERSE) {
                        sourceStart -= extendBy;
                    }
                    if (hitStrand == Location.FORWARD) {
                        hitEend += extendBy;
                    } else if (hitStrand == Location.REVERSE) {
                        hitStart -= extendBy;
                    }
                }
                // We also don't allow readings which are beyond the end of the chromosome
                if (sourceEend > chrs[c].length()) {
                    int overrun = sourceEend - chrs[c].length();
                    progressWarningReceived(new SeqMonkException("Reading position " + sourceEend + " was " + overrun + "bp beyond the end of chr" + chrs[c].name() + " (" + chrs[c].length() + ")"));
                    continue;
                }
                if (hitEend > localChromosome.length()) {
                    int overrun = hitEend - SeqMonkApplication.getInstance().dataCollection().genome().getChromosome(localChromosomes[c2]).chromosome().length();
                    progressWarningReceived(new SeqMonkException("Reading position " + hitEend + " was " + overrun + "bp beyond the end of chr" + localChromosome.name() + " (" + chrs[c].length() + ")"));
                    continue;
                }
                // We can now make the new readings
                long sourceRead = SequenceRead.packPosition(sourceStart, sourceEend, sourceStrand);
                long hitRead = SequenceRead.packPosition(hitStart, hitEend, hitStrand);
                if (!prefs.isHiC()) {
                    // HiC additions are deferred until we know the other end is OK too.
                    newData.addData(chrs[c], sourceRead);
                    newData.addData(localChromosome, hitRead);
                }
            }
        }
    }
    return newData;
}
Also used : HiCHitCollection(uk.ac.babraham.SeqMonk.DataTypes.Sequence.HiCHitCollection) PairedDataSet(uk.ac.babraham.SeqMonk.DataTypes.PairedDataSet) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) Feature(uk.ac.babraham.SeqMonk.DataTypes.Genome.Feature) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException)

Example 2 with HiCDataStore

use of uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore in project SeqMonk by s-andrews.

the class FourCEnrichmentQuantitation method quantitate.

/* (non-Javadoc)
	 * @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#quantitate(uk.ac.babraham.SeqMonk.DataTypes.DataStore[])
	 */
public void quantitate(DataStore[] data) {
    // Find the 4C looking data stores amongst the set we've been given
    Vector<DataSet> fourCStores = new Vector<DataSet>();
    for (int d = 0; d < data.length; d++) {
        if (data[d] instanceof HiCDataStore && ((HiCDataStore) data[d]).isValidHiC()) {
            progressWarningReceived(new SeqMonkException("Skipping " + data[d] + " which was HiC data"));
            continue;
        } else if (!(data[d] instanceof DataSet)) {
            // We can only analyse direct 4C data sets
            progressWarningReceived(new SeqMonkException("Skipping " + data[d] + " which wasn't a DataSet"));
            continue;
        } else if (!((DataSet) data[d]).fileName().startsWith("HiC other end")) {
            progressWarningReceived(new SeqMonkException("Skipping " + data[d] + " which didn't look like a 4C data set"));
            continue;
        }
        fourCStores.add((DataSet) data[d]);
    }
    this.data = fourCStores.toArray(new DataSet[0]);
    Thread t = new Thread(this);
    cancel = false;
    t.start();
}
Also used : DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Vector(java.util.Vector)

Example 3 with HiCDataStore

use of uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore in project SeqMonk by s-andrews.

the class HiCReadCountQuantitation method run.

/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
public void run() {
    Probe[] probes = application.dataCollection().probeSet().getAllProbes();
    float[] corrections = new float[data.length];
    if (correctTotal) {
        float largest = 0;
        if (correctPerMillion) {
            largest = 1000000;
        }
        for (int d = 0; d < data.length; d++) {
            // if (correctOnlyInProbes) {
            // corrections[d] = getTotalCountInProbes(data[d],probes);
            // }
            // else {
            corrections[d] = ((DataStore) data[d]).getTotalReadCount();
            // }
            if (d == 0 && !correctPerMillion) {
                largest = corrections[d];
            } else {
                if (!correctPerMillion && corrections[d] > largest) {
                    largest = corrections[d];
                }
            }
        }
        // We correct everything by the largest count
        for (int d = 0; d < corrections.length; d++) {
            corrections[d] = largest / corrections[d];
        }
    }
    for (int p = 0; p < probes.length; p++) {
        // See if we need to quit
        if (cancel) {
            progressCancelled();
            return;
        }
        double lengthCorrection = 1;
        if (correctLength) {
            // We assume a 'normal' probe length of 1kb
            lengthCorrection = (double) 1000 / probes[p].length();
        }
        progressUpdated(p, probes.length);
        for (int d = 0; d < data.length; d++) {
            double count = 0;
            HiCHitCollection hiCHits = data[d].getHiCReadsForProbe(probes[p]);
            String[] chromosomeNames = hiCHits.getChromosomeNamesWithHits();
            for (int c = 0; c < chromosomeNames.length; c++) {
                long[] sourceReads = hiCHits.getSourcePositionsForChromosome(chromosomeNames[c]);
                long[] hitReads = hiCHits.getHitPositionsForChromosome(chromosomeNames[c]);
                for (int r = 0; r < sourceReads.length; r++) {
                    // Check if we can ignore this one
                    if (removeDuplicates) {
                        if (r > 0 && sourceReads[r] == sourceReads[r - 1] && hitReads[r] == hitReads[r - 1])
                            continue;
                    }
                    if (SequenceRead.overlaps(hitReads[r], probes[p].packedPosition()) && SequenceRead.compare(hitReads[r], sourceReads[r]) > 0) {
                        continue;
                    }
                    ++count;
                }
            }
            if (logTransform && count == 0) {
                count = 0.9;
            }
            if (correctTotal) {
                count *= corrections[d];
            }
            if (correctLength) {
                count *= lengthCorrection;
            }
            if (logTransform) {
                count = (float) Math.log(count) / log2;
            }
            // TODO: This is icky since the inheritance between HiCDataStore and DataStore
            // isn't properly sorted out.
            ((DataStore) data[d]).setValueForProbe(probes[p], (float) count);
        }
    }
    quantitatonComplete();
}
Also used : HiCHitCollection(uk.ac.babraham.SeqMonk.DataTypes.Sequence.HiCHitCollection) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)

Example 4 with HiCDataStore

use of uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore 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 &gt; Preferences &gt; 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");
    }
}
Also used : QuantiationTrendPlotPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.QuantitationTrendPlot.QuantiationTrendPlotPreferencesDialog) BedPEFileParser(uk.ac.babraham.SeqMonk.DataParsers.BedPEFileParser) MalformedURLException(java.net.MalformedURLException) DuplicationPlotDialog(uk.ac.babraham.SeqMonk.Displays.DuplicationPlot.DuplicationPlotDialog) AboutDialog(uk.ac.babraham.SeqMonk.Dialogs.AboutDialog) LogisticRegressionSplicingFilter(uk.ac.babraham.SeqMonk.Filters.LogisticRegressionFilter.LogisticRegressionSplicingFilter) DefinePipelineOptions(uk.ac.babraham.SeqMonk.Pipelines.Options.DefinePipelineOptions) MethylKitFileParser(uk.ac.babraham.SeqMonk.DataParsers.MethylKitFileParser) EdgeRFilter(uk.ac.babraham.SeqMonk.Filters.EdgeRFilter.EdgeRFilter) GenericAnnotationParser(uk.ac.babraham.SeqMonk.AnnotationParsers.GenericAnnotationParser) ProbeLengthHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.ProbeLengthHistogramPlot) WindowedValuesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedValuesFilter) VarianceValuesFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceValuesFilter) ValuesFilter(uk.ac.babraham.SeqMonk.Filters.ValuesFilter) FeatureNameFilter(uk.ac.babraham.SeqMonk.Filters.FeatureNameFilter) VarianceIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceIntensityDifferenceFilter) LogisticRegressionFilter(uk.ac.babraham.SeqMonk.Filters.LogisticRegressionFilter.LogisticRegressionFilter) DeduplicationFilter(uk.ac.babraham.SeqMonk.Filters.DeduplicationFilter) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) DisplayPreferencesEditorDialog(uk.ac.babraham.SeqMonk.Preferences.Editor.DisplayPreferencesEditorDialog) CumulativeDistributionDialog(uk.ac.babraham.SeqMonk.Displays.CumulativeDistribution.CumulativeDistributionDialog) LineGraphDialog(uk.ac.babraham.SeqMonk.Displays.LineGraph.LineGraphDialog) GiraphPlot(uk.ac.babraham.SeqMonk.Displays.GiraphPlot.GiraphPlot) ReplicateSetEditor(uk.ac.babraham.SeqMonk.Dialogs.ReplicateSetEditor) VarianceIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceIntensityDifferenceFilter) GeneSetIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.GeneSetFilter.GeneSetIntensityDifferenceFilter) IntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.IntensityDifferenceFilter) ReplicateSetStatsFilter(uk.ac.babraham.SeqMonk.Filters.ReplicateSetStatsFilter) SmallRNAQCPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.SmallRNAQCPlot.SmallRNAQCPreferencesDialog) RNAQCPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.RNASeqQCPlot.RNAQCPreferencesDialog) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) WindowedDifferencesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedDifferencesFilter) BedGraphDataWriter(uk.ac.babraham.SeqMonk.DataWriters.BedGraphDataWriter) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) GffFileParser(uk.ac.babraham.SeqMonk.DataParsers.GffFileParser) LimmaFilter(uk.ac.babraham.SeqMonk.Filters.LimmaFilter.LimmaFilter) DistributionPositionFilter(uk.ac.babraham.SeqMonk.Filters.DistributionPositionFilter) PositionFilter(uk.ac.babraham.SeqMonk.Filters.PositionFilter) SeqMonkReimportParser(uk.ac.babraham.SeqMonk.DataParsers.SeqMonkReimportParser) MultiBeanPlotDialog(uk.ac.babraham.SeqMonk.Displays.BeanPlot.MultiBeanPlotDialog) ProbeGroupReport(uk.ac.babraham.SeqMonk.Reports.ProbeGroupReport) PCADataCalculator(uk.ac.babraham.SeqMonk.Displays.PCAPlot.PCADataCalculator) DataZoomSelector(uk.ac.babraham.SeqMonk.Dialogs.DataZoomSelector) BoxWhiskerFilter(uk.ac.babraham.SeqMonk.Filters.BoxWhiskerFilter) ActiveProbeListParser(uk.ac.babraham.SeqMonk.DataParsers.ActiveProbeListParser) MonteCarloFilter(uk.ac.babraham.SeqMonk.Filters.MonteCarloFilter) QQDistributionDialog(uk.ac.babraham.SeqMonk.Displays.QQDistributionPlot.QQDistributionDialog) HiCLengthHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.HiCLengthHistogramPlot) ProbeNameFilter(uk.ac.babraham.SeqMonk.Filters.ProbeNameFilter) FeatureFilter(uk.ac.babraham.SeqMonk.Filters.FeatureFilter) FeatureReport(uk.ac.babraham.SeqMonk.Reports.FeatureReport) BismarkCovFileParser(uk.ac.babraham.SeqMonk.DataParsers.BismarkCovFileParser) ProbeValueHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.ProbeValueHistogramPlot) ProbeListAnnotationParser(uk.ac.babraham.SeqMonk.AnnotationParsers.ProbeListAnnotationParser) URL(java.net.URL) GroupEditor(uk.ac.babraham.SeqMonk.Dialogs.GroupEditor) ChiSquareFilter(uk.ac.babraham.SeqMonk.Filters.ChiSquareFilter) GotoDialog(uk.ac.babraham.SeqMonk.Dialogs.GotoDialog.GotoDialog) AlignedSummaryPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.AlignedProbePlot.AlignedSummaryPreferencesDialog) HelpDialog(uk.ac.babraham.SeqMonk.Displays.Help.HelpDialog) BowtieFileParser(uk.ac.babraham.SeqMonk.DataParsers.BowtieFileParser) LicenseDialog(uk.ac.babraham.SeqMonk.Dialogs.LicenseDialog) ListOverlapsDialog(uk.ac.babraham.SeqMonk.Dialogs.ListOverlapsDialog) MultiBoxWhiskerDialog(uk.ac.babraham.SeqMonk.Displays.BoxWhisker.MultiBoxWhiskerDialog) TsneOptionsDialog(uk.ac.babraham.SeqMonk.Displays.TsneDataStorePlot.TsneOptionsDialog) BinomialFilterForRev(uk.ac.babraham.SeqMonk.Filters.BinomialFilterForRev) ManualCorrelationFilter(uk.ac.babraham.SeqMonk.Filters.ManualCorrelation.ManualCorrelationFilter) IOException(java.io.IOException) IntensityReplicateFilter(uk.ac.babraham.SeqMonk.Filters.IntensityReplicateFilter) ChiSquareFilterFrontBack(uk.ac.babraham.SeqMonk.Filters.ChiSquareFilterFrontBack) AnnotatedListReport(uk.ac.babraham.SeqMonk.Reports.AnnotatedListReport) AnnotationTrackSelector(uk.ac.babraham.SeqMonk.Dialogs.AnnotationTrackSelector) GeneSetIntensityDifferenceFilter(uk.ac.babraham.SeqMonk.Filters.GeneSetFilter.GeneSetIntensityDifferenceFilter) MAPlotDialog(uk.ac.babraham.SeqMonk.Displays.MAPlot.MAPlotDialog) Clipboard(java.awt.datatransfer.Clipboard) ProbeLengthFilter(uk.ac.babraham.SeqMonk.Filters.ProbeLengthFilter) GenericSeqReadParser(uk.ac.babraham.SeqMonk.DataParsers.GenericSeqReadParser) GotoWindowDialog(uk.ac.babraham.SeqMonk.Dialogs.GotoDialog.GotoWindowDialog) ProbeListReportCreator(uk.ac.babraham.SeqMonk.Displays.ProbeListReport.ProbeListReportCreator) FilterOptionsDialog(uk.ac.babraham.SeqMonk.Dialogs.Filters.FilterOptionsDialog) CorrelationClusterFilter(uk.ac.babraham.SeqMonk.Filters.CorrelationCluster.CorrelationClusterFilter) StringSelection(java.awt.datatransfer.StringSelection) CorrelationMatrix(uk.ac.babraham.SeqMonk.Displays.CorrelationMatrix.CorrelationMatrix) DefineProbeOptions(uk.ac.babraham.SeqMonk.ProbeGenerators.DefineProbeOptions) TrendOverProbePreferencesDialog(uk.ac.babraham.SeqMonk.Displays.ProbeTrendPlot.TrendOverProbePreferencesDialog) CombineFilter(uk.ac.babraham.SeqMonk.Filters.CombineFilter) CollateListsFilter(uk.ac.babraham.SeqMonk.Filters.CollateListsFilter) FindFeaturesByNameDialog(uk.ac.babraham.SeqMonk.Dialogs.FindFeaturesByNameDialog) DataSetEditor(uk.ac.babraham.SeqMonk.Dialogs.DataSetEditor.DataSetEditor) DomainogramPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.Domainogram.DomainogramPreferencesDialog) ReportOptions(uk.ac.babraham.SeqMonk.Displays.Report.ReportOptions) ChiSquareFilterForRev(uk.ac.babraham.SeqMonk.Filters.ChiSquareFilterForRev) DataStoreSummaryReport(uk.ac.babraham.SeqMonk.Reports.DataStoreSummaryReport) EdgeRForRevFilter(uk.ac.babraham.SeqMonk.Filters.EdgeRFilter.EdgeRForRevFilter) VariancePlotDialog(uk.ac.babraham.SeqMonk.Displays.VariancePlot.VariancePlotDialog) WindowedValuesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedValuesFilter) DESeqFilter(uk.ac.babraham.SeqMonk.Filters.DESeqFilter.DESeqFilter) HeatmapGenomeWindow(uk.ac.babraham.SeqMonk.Displays.HiCHeatmap.HeatmapGenomeWindow) MultiStarWarsDialog(uk.ac.babraham.SeqMonk.Displays.StarWars.MultiStarWarsDialog) VarianceValuesFilter(uk.ac.babraham.SeqMonk.Filters.Variance.VarianceValuesFilter) ManualCorrelationFilter(uk.ac.babraham.SeqMonk.Filters.ManualCorrelation.ManualCorrelationFilter) CorrelationFilter(uk.ac.babraham.SeqMonk.Filters.CorrelationFilter) DifferencesFilter(uk.ac.babraham.SeqMonk.Filters.DifferencesFilter) WindowedDifferencesFilter(uk.ac.babraham.SeqMonk.Filters.WindowedDifferencesFilter) VisibleStoresParser(uk.ac.babraham.SeqMonk.DataParsers.VisibleStoresParser) AutoSplitDataDialog(uk.ac.babraham.SeqMonk.Dialogs.AutoSplitDataDialog) File(java.io.File) ProportionOfLibraryStatisticsFilter(uk.ac.babraham.SeqMonk.Filters.ProportionOfLibraryStatisticsFilter) BedFileParser(uk.ac.babraham.SeqMonk.DataParsers.BedFileParser) StrandBiasPlotDialog(uk.ac.babraham.SeqMonk.Displays.StrandBias.StrandBiasPlotDialog) URISyntaxException(java.net.URISyntaxException) RandomFilter(uk.ac.babraham.SeqMonk.Filters.RandomFilter) DataStoreTreeDialog(uk.ac.babraham.SeqMonk.Displays.DataStoreTree.DataStoreTreeDialog) ReadLengthHistogramPlot(uk.ac.babraham.SeqMonk.Displays.HistogramPlot.ReadLengthHistogramPlot) HierarchicalClusterDialog(uk.ac.babraham.SeqMonk.Displays.HierarchicalClusterPlot.HierarchicalClusterDialog) GFF3AnnotationParser(uk.ac.babraham.SeqMonk.AnnotationParsers.GFF3AnnotationParser) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) HiCOtherEndExtractor(uk.ac.babraham.SeqMonk.DataParsers.HiCOtherEndExtractor) DataTrackSelector(uk.ac.babraham.SeqMonk.Dialogs.DataTrackSelector.DataTrackSelector) WindowedReplicateStatsFilter(uk.ac.babraham.SeqMonk.Filters.WindowedReplicateStatsFilter) EditPreferencesDialog(uk.ac.babraham.SeqMonk.Dialogs.EditPreferencesDialog) HeatmapProbeListWindow(uk.ac.babraham.SeqMonk.Displays.HiCHeatmap.HeatmapProbeListWindow) Transferable(java.awt.datatransfer.Transferable) SmallRNAQCPreferencesDialog(uk.ac.babraham.SeqMonk.Displays.SmallRNAQCPlot.SmallRNAQCPreferencesDialog) FindFeatureDialog(uk.ac.babraham.SeqMonk.Dialogs.FindFeatureDialog) DistributionPositionFilter(uk.ac.babraham.SeqMonk.Filters.DistributionPositionFilter) ScatterPlotDialog(uk.ac.babraham.SeqMonk.Displays.ScatterPlot.ScatterPlotDialog) CisTransScatterPlotDialog(uk.ac.babraham.SeqMonk.Displays.CisTransScatterplot.CisTransScatterPlotDialog) ChromosomeViewReport(uk.ac.babraham.SeqMonk.Reports.ChromosomeViewReport) CisTransScatterPlotDialog(uk.ac.babraham.SeqMonk.Displays.CisTransScatterplot.CisTransScatterPlotDialog) DefineQuantitationOptions(uk.ac.babraham.SeqMonk.Quantitation.Options.DefineQuantitationOptions) BAMFileParser(uk.ac.babraham.SeqMonk.DataParsers.BAMFileParser) QuasRFileParser(uk.ac.babraham.SeqMonk.DataParsers.QuasRFileParser)

Example 5 with HiCDataStore

use of uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore in project SeqMonk by s-andrews.

the class ChromosomeDataTrack method getHiCPixelCounts.

private int[][] getHiCPixelCounts() {
    // Check if we're able to use the last cached data.
    if (lastWidth == width && viewer.currentStart() == lastStart && viewer.currentEnd() == lastEnd && cachedHiCPixelCounts != null) {
        return cachedHiCPixelCounts;
    }
    lastWidth = width;
    lastStart = viewer.currentStart();
    lastEnd = viewer.currentEnd();
    cachedHiCPixelCounts = new int[width + 1][width + 1];
    if (lastChromosome != viewer.chromosome()) {
        HiCHitCollection col = ((HiCDataStore) data).getHiCReadsForChromosome(viewer.chromosome());
        lastSourceHiC = col.getSourcePositionsForChromosome(viewer.chromosome().name());
        lastHitHic = col.getHitPositionsForChromosome(viewer.chromosome().name());
        lastChromosome = viewer.chromosome();
    // Check if the HiC collection is sorted.
    // for (int i=1;i<lastSourceHiC.length;i++) {
    // if (SequenceRead.start(lastSourceHiC[i-1]) > SequenceRead.start(lastSourceHiC[i])) {
    // throw new IllegalStateException("HiC set isn't sorted");
    // }
    // }
    }
    // No need to do anything more if there's no data
    if (lastSourceHiC.length == 0)
        return cachedHiCPixelCounts;
    // Go back until we're sure we're not going to see any more reads
    for (int i = lastInteractionIndexStart; i >= 0; i--) {
        if (i >= lastSourceHiC.length)
            continue;
        if (SequenceRead.start(lastSourceHiC[i]) < viewer.currentStart() - data.getMaxReadLength()) {
            lastInteractionIndexStart = i;
            break;
        }
    }
    // Go forward until we hit our first read
    for (int i = lastInteractionIndexStart; i < reads.length; i++) {
        if (SequenceRead.start(lastSourceHiC[i]) >= viewer.currentStart() - data.getMaxReadLength()) {
            lastInteractionIndexStart = i;
            break;
        }
    }
    for (int i = lastInteractionIndexStart; i < lastSourceHiC.length; i++) {
        // Check if both of the ends are in the current window
        int sourceMidPoint = SequenceRead.midPoint(lastSourceHiC[i]);
        if (SequenceRead.start(lastSourceHiC[i]) > viewer.currentEnd()) {
            break;
        }
        if (sourceMidPoint < viewer.currentStart() || sourceMidPoint > viewer.currentEnd()) {
            continue;
        }
        int hitMidPoint = SequenceRead.midPoint(lastHitHic[i]);
        if (hitMidPoint < viewer.currentStart() || hitMidPoint > viewer.currentEnd()) {
            continue;
        }
        int sourcePixel = bpToPixel(Math.min(sourceMidPoint, hitMidPoint));
        int hitPixel = bpToPixel(Math.max(sourceMidPoint, hitMidPoint));
        // System.err.println("Found valid interaction between "+sourceMidPoint+" and "+hitMidPoint+" which is "+sourcePixel+" to "+hitPixel);
        // Now we can add the interaction to the matrix
        cachedHiCPixelCounts[sourcePixel][hitPixel]++;
    }
    return cachedHiCPixelCounts;
}
Also used : HiCHitCollection(uk.ac.babraham.SeqMonk.DataTypes.Sequence.HiCHitCollection) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore)

Aggregations

HiCDataStore (uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore)12 HiCHitCollection (uk.ac.babraham.SeqMonk.DataTypes.Sequence.HiCHitCollection)6 SeqMonkException (uk.ac.babraham.SeqMonk.SeqMonkException)5 DataStore (uk.ac.babraham.SeqMonk.DataTypes.DataStore)4 Probe (uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)4 ProbeList (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)4 DataSet (uk.ac.babraham.SeqMonk.DataTypes.DataSet)3 Chromosome (uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)3 JLabel (javax.swing.JLabel)2 DataGroup (uk.ac.babraham.SeqMonk.DataTypes.DataGroup)2 Font (java.awt.Font)1 Graphics2D (java.awt.Graphics2D)1 Clipboard (java.awt.datatransfer.Clipboard)1 StringSelection (java.awt.datatransfer.StringSelection)1 Transferable (java.awt.datatransfer.Transferable)1 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1