Search in sources :

Example 1 with InteractionReportOptions

use of uk.ac.babraham.SeqMonk.Displays.Report.InteractionReport.InteractionReportOptions in project SeqMonk by s-andrews.

the class HeatmapProbeListWindow method actionPerformed.

/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("close")) {
        setVisible(false);
        dispose();
    } else if (ae.getActionCommand().equals("save_image")) {
        ImageSaver.saveImage(heatmapPanel);
    } else if (ae.getActionCommand().equals("cluster")) {
        if (clusterButton.getText().equals("Cluster Interactions")) {
            // First we need to make up an interaction cluster matrix which we
            // can then feed to the generic hierarchical clustering program
            InteractionClusterMatrix clusterMatrix = new InteractionClusterMatrix(matrix.filteredInteractions(), matrix.probeCount());
            clusterMatrix.addListener(new ProgressDialog(this, "HiC Interaction Clustering", clusterMatrix));
            clusterMatrix.addListener(this);
            clusterMatrix.startCorrelating();
            clusterButton.setEnabled(false);
        } else {
            matrix.setCluster(null);
            saveClustersButton.setEnabled(false);
            clusterButton.setText("Cluster Interactions");
        }
    } else if (ae.getActionCommand().equals("save_probes")) {
        ProbeList newList = matrix.createProbeListFromCurrentInteractions();
        // Ask for a name for the list
        String groupName = null;
        while (true) {
            groupName = (String) JOptionPane.showInputDialog(this, "Enter list name", "Found " + newList.getAllProbes().length + " probes", JOptionPane.QUESTION_MESSAGE, null, null, newList.name());
            if (groupName == null) {
                // Since the list will automatically have been added to
                // the ProbeList tree we actively need to delete it if
                // they choose to cancel at this point.
                newList.delete();
                // They cancelled
                return;
            }
            if (groupName.length() == 0)
                // Try again
                continue;
            break;
        }
        newList.setName(groupName);
    } else if (ae.getActionCommand().equals("save_clusters")) {
        if (matrix.cluster() == null)
            return;
        // Get a limit for how many probes per cluster
        String howManyProbes = JOptionPane.showInputDialog(this, "Minimum number of probes per cluster", "10");
        if (howManyProbes == null)
            return;
        int minProbes;
        try {
            minProbes = Integer.parseInt(howManyProbes);
        } catch (NumberFormatException nfe) {
            JOptionPane.showMessageDialog(this, howManyProbes + " was not an integer", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        ProbeList newList = matrix.createProbeListsFromClusters(minProbes, heatmapPanel.probeListPanel().currentYStartIndex(), heatmapPanel.probeListPanel().currentYEndIndex());
        // This was called before clustering had completed.
        if (newList == null)
            return;
        // Ask for a name for the list
        String groupName = null;
        while (true) {
            groupName = (String) JOptionPane.showInputDialog(this, "Enter list name", "Found " + newList.getAllProbes().length + " probes", JOptionPane.QUESTION_MESSAGE, null, null, newList.name());
            if (groupName == null) {
                // Since the list will automatically have been added to
                // the ProbeList tree we actively need to delete it if
                // they choose to cancel at this point.
                newList.delete();
                // They cancelled
                return;
            }
            if (groupName.length() == 0)
                // Try again
                continue;
            break;
        }
        newList.setName(groupName);
    } else if (ae.getActionCommand().equals("make_report")) {
        new InteractionReportOptions(SeqMonkApplication.getInstance(), new AnnotatedInteractionReport(SeqMonkApplication.getInstance().dataCollection(), matrix));
    }
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) InteractionClusterMatrix(uk.ac.babraham.SeqMonk.DataTypes.Interaction.InteractionClusterMatrix) InteractionReportOptions(uk.ac.babraham.SeqMonk.Displays.Report.InteractionReport.InteractionReportOptions) ProgressDialog(uk.ac.babraham.SeqMonk.Dialogs.ProgressDialog.ProgressDialog) AnnotatedInteractionReport(uk.ac.babraham.SeqMonk.Reports.Interaction.AnnotatedInteractionReport)

Example 2 with InteractionReportOptions

use of uk.ac.babraham.SeqMonk.Displays.Report.InteractionReport.InteractionReportOptions in project SeqMonk by s-andrews.

the class HeatmapGenomeWindow method actionPerformed.

/* (non-Javadoc)
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
public void actionPerformed(ActionEvent ae) {
    if (ae.getActionCommand().equals("close")) {
        setVisible(false);
        dispose();
    } else if (ae.getActionCommand().equals("save_image")) {
        ImageSaver.saveImage(heatmapPanel);
    } else if (ae.getActionCommand().equals("cluster")) {
        if (clusterButton.getText().equals("Cluster Interactions")) {
            // First we need to make up an interaction cluster matrix which we
            // can then feed to the generic hierarchical clustering program
            InteractionClusterMatrix clusterMatrix = new InteractionClusterMatrix(matrix.filteredInteractions(), matrix.probeCount());
            clusterMatrix.addListener(new ProgressDialog(this, "HiC Interaction Clustering", clusterMatrix));
            clusterMatrix.addListener(this);
            clusterMatrix.startCorrelating();
            clusterButton.setEnabled(false);
        } else {
            matrix.setCluster(null);
            saveClustersButton.setEnabled(false);
            clusterButton.setText("Cluster Interactions");
        }
    } else if (ae.getActionCommand().equals("save_probes")) {
        ProbeList newList = matrix.createProbeListFromCurrentInteractions();
        // Ask for a name for the list
        String groupName = null;
        while (true) {
            groupName = (String) JOptionPane.showInputDialog(this, "Enter list name", "Found " + newList.getAllProbes().length + " probes", JOptionPane.QUESTION_MESSAGE, null, null, newList.name());
            if (groupName == null) {
                // Since the list will automatically have been added to
                // the ProbeList tree we actively need to delete it if
                // they choose to cancel at this point.
                newList.delete();
                // They cancelled
                return;
            }
            if (groupName.length() == 0)
                // Try again
                continue;
            break;
        }
        newList.setName(groupName);
    } else if (ae.getActionCommand().equals("save_clusters")) {
        if (matrix.cluster() == null)
            return;
        // Get a limit for how many probes per cluster
        String howManyProbes = JOptionPane.showInputDialog(this, "Minimum number of probes per cluster", "10");
        if (howManyProbes == null)
            return;
        int minProbes;
        try {
            minProbes = Integer.parseInt(howManyProbes);
        } catch (NumberFormatException nfe) {
            JOptionPane.showMessageDialog(this, howManyProbes + " was not an integer", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        ProbeList newList = matrix.createProbeListsFromClusters(minProbes, heatmapPanel.genomePanel().currentYStartIndex(), heatmapPanel.genomePanel().currentYEndIndex());
        // This was called before clustering had completed.
        if (newList == null)
            return;
        // Ask for a name for the list
        String groupName = null;
        while (true) {
            groupName = (String) JOptionPane.showInputDialog(this, "Enter list name", "Found " + newList.getAllProbes().length + " probes", JOptionPane.QUESTION_MESSAGE, null, null, newList.name());
            if (groupName == null) {
                // Since the list will automatically have been added to
                // the ProbeList tree we actively need to delete it if
                // they choose to cancel at this point.
                newList.delete();
                // They cancelled
                return;
            }
            if (groupName.length() == 0)
                // Try again
                continue;
            break;
        }
        newList.setName(groupName);
    } else if (ae.getActionCommand().equals("send_x")) {
        DisplayPreferences.getInstance().setLocation(xChr, SequenceRead.packPosition(xStart, xEnd, Location.UNKNOWN));
    } else if (ae.getActionCommand().equals("send_y")) {
        DisplayPreferences.getInstance().setLocation(yChr, SequenceRead.packPosition(yStart, yEnd, Location.UNKNOWN));
    } else if (ae.getActionCommand().equals("match")) {
        Chromosome chr = DisplayPreferences.getInstance().getCurrentChromosome();
        int start = SequenceRead.start(DisplayPreferences.getInstance().getCurrentLocation());
        int end = SequenceRead.end(DisplayPreferences.getInstance().getCurrentLocation());
        heatmapPanel.genomePanel().setCurrentPosition(chr, start, end);
    } else if (ae.getActionCommand().equals("make_report")) {
        new InteractionReportOptions(SeqMonkApplication.getInstance(), new AnnotatedInteractionReport(SeqMonkApplication.getInstance().dataCollection(), matrix));
    }
}
Also used : ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) InteractionClusterMatrix(uk.ac.babraham.SeqMonk.DataTypes.Interaction.InteractionClusterMatrix) InteractionReportOptions(uk.ac.babraham.SeqMonk.Displays.Report.InteractionReport.InteractionReportOptions) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) ProgressDialog(uk.ac.babraham.SeqMonk.Dialogs.ProgressDialog.ProgressDialog) AnnotatedInteractionReport(uk.ac.babraham.SeqMonk.Reports.Interaction.AnnotatedInteractionReport)

Aggregations

InteractionClusterMatrix (uk.ac.babraham.SeqMonk.DataTypes.Interaction.InteractionClusterMatrix)2 ProbeList (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)2 ProgressDialog (uk.ac.babraham.SeqMonk.Dialogs.ProgressDialog.ProgressDialog)2 InteractionReportOptions (uk.ac.babraham.SeqMonk.Displays.Report.InteractionReport.InteractionReportOptions)2 AnnotatedInteractionReport (uk.ac.babraham.SeqMonk.Reports.Interaction.AnnotatedInteractionReport)2 Chromosome (uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)1