Search in sources :

Example 1 with DataGroup

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

the class LogTransformQuantitation method run.

/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
public void run() {
    if (!isReady()) {
        progressExceptionReceived(new SeqMonkException("Options weren't set correctly"));
    }
    Chromosome[] chromosomes = application.dataCollection().genome().getAllChromosomes();
    Vector<DataStore> quantitatedStores = new Vector<DataStore>();
    DataSet[] sets = application.dataCollection().getAllDataSets();
    for (int s = 0; s < sets.length; s++) {
        if (sets[s].isQuantitated()) {
            quantitatedStores.add(sets[s]);
        }
    }
    DataGroup[] groups = application.dataCollection().getAllDataGroups();
    for (int g = 0; g < groups.length; g++) {
        if (groups[g].isQuantitated()) {
            quantitatedStores.add(groups[g]);
        }
    }
    DataStore[] data = quantitatedStores.toArray(new DataStore[0]);
    for (int c = 0; c < chromosomes.length; c++) {
        // See if we need to quit
        if (cancel) {
            progressCancelled();
            return;
        }
        progressUpdated(c, chromosomes.length);
        Probe[] allProbes = application.dataCollection().probeSet().getProbesForChromosome(chromosomes[c]);
        try {
            for (int p = 0; p < allProbes.length; p++) {
                // See if we need to quit
                if (cancel) {
                    progressCancelled();
                    return;
                }
                for (int d = 0; d < data.length; d++) {
                    data[d].setValueForProbe(allProbes[p], (float) (Math.log(Math.max(data[d].getValueForProbe(allProbes[p]), threshold)) / Math.log(logBase)));
                }
            }
        } catch (SeqMonkException e) {
            progressExceptionReceived(e);
        }
    }
    quantitatonComplete();
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) Chromosome(uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) Vector(java.util.Vector)

Example 2 with DataGroup

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

the class DataTreeRenderer method getTreeCellRendererComponent.

/* (non-Javadoc)
	 * @see javax.swing.tree.DefaultTreeCellRenderer#getTreeCellRendererComponent(javax.swing.JTree, java.lang.Object, boolean, boolean, boolean, int, boolean)
	 */
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    if (value instanceof DataSet) {
        JLabel label = new JLabel(value.toString(), dataSetIcon, JLabel.LEFT);
        if (value instanceof HiCDataStore && ((HiCDataStore) value).isValidHiC()) {
            label.setText("[HiC] " + label.getText());
        }
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof DataGroup) {
        JLabel label = new JLabel(value.toString(), dataGroupIcon, JLabel.LEFT);
        if (value instanceof HiCDataStore && ((HiCDataStore) value).isValidHiC()) {
            label.setText("[HiC] " + label.getText());
        }
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof ReplicateSet) {
        JLabel label = new JLabel(value.toString(), replicateSetIcon, JLabel.LEFT);
        if (value instanceof HiCDataStore && ((HiCDataStore) value).isValidHiC()) {
            label.setText("[HiC] " + label.getText());
        }
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof ProbeList) {
        JLabel label = new JLabel(value.toString(), probeListIcon, JLabel.LEFT);
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else if (value instanceof AnnotationSet) {
        JLabel label = new JLabel(value.toString(), annotationSetIcon, JLabel.LEFT);
        if (selected) {
            label.setOpaque(true);
            label.setBackground(Color.LIGHT_GRAY);
        }
        return label;
    } else {
        return super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
    }
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) ProbeList(uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) ReplicateSet(uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet) JLabel(javax.swing.JLabel) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore) AnnotationSet(uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationSet)

Example 3 with DataGroup

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

the class AutoSplitDataDialog method createGroups.

private void createGroups() {
    String[] names = groupNamesArea.getText().split("\\n");
    int[] counts = new int[names.length];
    DataSet[] dataSets = application.dataCollection().getAllDataSets();
    DataGroup[] dataGroups = application.dataCollection().getAllDataGroups();
    boolean makeReplicateSets = groupsOrSetsBox.getSelectedItem().equals("Replicate Sets");
    boolean caseInsensitive = caseInsensitiveBox.isSelected();
    if (!includeGroupsBox.isSelected()) {
        dataGroups = new DataGroup[0];
    }
    boolean[] setsFound = new boolean[dataSets.length];
    boolean[] groupsFound = new boolean[dataGroups.length];
    for (int n = 0; n < names.length; n++) {
        if (names[n].trim().length() == 0)
            continue;
        names[n] = names[n].trim();
        String[] patterns = names[n].split("\\|");
        if (makeReplicateSets) {
            Vector<DataStore> stores = new Vector<DataStore>();
            DATASET: for (int i = 0; i < dataSets.length; i++) {
                // Only add to the first match we make
                if (setsFound[i])
                    continue;
                for (int p = 0; p < patterns.length; p++) {
                    if (caseInsensitive) {
                        if (!dataSets[i].name().toLowerCase().contains(patterns[p].toLowerCase())) {
                            continue DATASET;
                        }
                    } else {
                        if (!dataSets[i].name().contains(patterns[p])) {
                            continue DATASET;
                        }
                    }
                }
                stores.add(dataSets[i]);
                setsFound[i] = true;
            }
            DATAGROUP: for (int i = 0; i < dataGroups.length; i++) {
                // Only add to the first match we make
                if (groupsFound[i])
                    continue;
                for (int p = 0; p < patterns.length; p++) {
                    if (!dataGroups[i].name().contains(patterns[p])) {
                        continue DATAGROUP;
                    }
                }
                stores.add(dataGroups[i]);
                groupsFound[i] = true;
            }
            counts[n] = stores.size();
            if (stores.size() > 0) {
                application.dataCollection().addReplicateSet(new ReplicateSet(names[n], stores.toArray(new DataStore[0])));
            }
        } else {
            Vector<DataSet> sets = new Vector<DataSet>();
            DATASET: for (int i = 0; i < dataSets.length; i++) {
                for (int p = 0; p < patterns.length; p++) {
                    if (!dataSets[i].name().contains(patterns[p])) {
                        continue DATASET;
                    }
                }
                sets.add(dataSets[i]);
            }
            counts[n] = sets.size();
            if (sets.size() > 0) {
                application.dataCollection().addDataGroup(new DataGroup(names[n], sets.toArray(new DataSet[0])));
            }
        }
    }
    StringBuffer sb = new StringBuffer();
    sb.append("<html>");
    for (int i = 0; i < names.length; i++) {
        sb.append("For name ");
        sb.append(names[i]);
        sb.append(" found ");
        sb.append(counts[i]);
        sb.append(" hits<br>");
    }
    sb.append("</html>");
    JOptionPane.showMessageDialog(this, sb.toString(), "Group creation complete", JOptionPane.INFORMATION_MESSAGE);
// It's actually better not to close after this but let them close it themselves.
// setVisible(false);
// dispose();
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) ReplicateSet(uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet) DataStore(uk.ac.babraham.SeqMonk.DataTypes.DataStore) Vector(java.util.Vector)

Example 4 with DataGroup

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

the class TypeColourRenderer method getListCellRendererComponent.

public Component getListCellRendererComponent(JList list, Object value, int index, boolean selected, boolean hasFocus) {
    // will make it do something more sensible
    if (value == null) {
        return new JLabel("null");
    }
    JLabel l = new JLabel(value.toString());
    if (value instanceof HiCDataStore) {
        if (((HiCDataStore) value).isValidHiC()) {
            l.setText("[HiC] " + l.getText());
        }
    }
    if (value instanceof DataSet) {
        l.setForeground(ColourScheme.DATASET_LIST);
        l.setBackground(ColourScheme.DATASET_LIST);
    } else if (value instanceof DataGroup) {
        l.setForeground(ColourScheme.DATAGROUP_LIST);
        l.setBackground(ColourScheme.DATAGROUP_LIST);
    } else {
        // Should only be replicate sets
        l.setForeground(ColourScheme.REPLICATE_SET_LIST);
        l.setBackground(ColourScheme.REPLICATE_SET_LIST);
    }
    if (selected) {
        l.setForeground(Color.WHITE);
        l.setOpaque(true);
    }
    return l;
}
Also used : DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) JLabel(javax.swing.JLabel) HiCDataStore(uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore)

Example 5 with DataGroup

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

the class SeqMonkDataWriter method run.

/* (non-Javadoc)
	 * @see java.lang.Runnable#run()
	 */
public void run() {
    try {
        // Generate a temp file in the same directory as the final
        // destination
        tempFile = File.createTempFile("seqmonk", ".temp", file.getParentFile());
        BufferedOutputStream bos;
        if (SeqMonkPreferences.getInstance().compressOutput()) {
            bos = new BufferedOutputStream(new GZIPOutputStream(new FileOutputStream(tempFile), 2048));
        } else {
            bos = new BufferedOutputStream(new FileOutputStream(tempFile));
        }
        PrintStream p = new PrintStream(bos);
        printDataVersion(p);
        printAssembly(p);
        DataSet[] dataSets = data.getAllDataSets();
        DataGroup[] dataGroups = data.getAllDataGroups();
        ReplicateSet[] replicateSets = data.getAllReplicateSets();
        if (!printDataSets(dataSets, p)) {
            // They cancelled
            return;
        }
        printDataGroups(dataSets, dataGroups, p);
        printReplicateSets(dataSets, dataGroups, replicateSets, p);
        AnnotationSet[] annotationSets = data.genome().annotationCollection().anotationSets();
        for (int a = 0; a < annotationSets.length; a++) {
            if (annotationSets[a] instanceof CoreAnnotationSet)
                continue;
            if (!printAnnotationSet(annotationSets[a], p)) {
                // They cancelled
                return;
            }
        }
        Probe[] probes = null;
        if (data.probeSet() != null) {
            probes = data.probeSet().getAllProbes();
        }
        if (probes != null) {
            if (!printProbeSet(data.probeSet(), probes, dataSets, dataGroups, p)) {
                // They cancelled
                return;
            }
        }
        if (visibleStores != null) {
            printVisibleDataStores(dataSets, dataGroups, replicateSets, p);
        }
        if (probes != null) {
            if (!printProbeLists(probes, p)) {
                // They cancelled
                return;
            }
        }
        if (defaultFeatureTracks != null) {
            printDisplayPreferences(p);
        }
        p.close();
        // We can now overwrite the original file
        if (file.exists()) {
            if (!file.delete()) {
                throw new IOException("Couldn't delete old project file when making new one");
            }
        }
        if (!tempFile.renameTo(file)) {
            throw new IOException("Failed to rename temporary file");
        }
        Enumeration<ProgressListener> e = listeners.elements();
        while (e.hasMoreElements()) {
            e.nextElement().progressComplete("data_written", null);
        }
    } catch (Exception ex) {
        Enumeration<ProgressListener> e = listeners.elements();
        while (e.hasMoreElements()) {
            e.nextElement().progressExceptionReceived(ex);
        }
    }
}
Also used : PrintStream(java.io.PrintStream) DataGroup(uk.ac.babraham.SeqMonk.DataTypes.DataGroup) Enumeration(java.util.Enumeration) DataSet(uk.ac.babraham.SeqMonk.DataTypes.DataSet) PairedDataSet(uk.ac.babraham.SeqMonk.DataTypes.PairedDataSet) ReplicateSet(uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet) AnnotationSet(uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationSet) CoreAnnotationSet(uk.ac.babraham.SeqMonk.DataTypes.Genome.CoreAnnotationSet) IOException(java.io.IOException) Probe(uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe) IOException(java.io.IOException) SeqMonkException(uk.ac.babraham.SeqMonk.SeqMonkException) CoreAnnotationSet(uk.ac.babraham.SeqMonk.DataTypes.Genome.CoreAnnotationSet) ProgressListener(uk.ac.babraham.SeqMonk.DataTypes.ProgressListener) GZIPOutputStream(java.util.zip.GZIPOutputStream) FileOutputStream(java.io.FileOutputStream) BufferedOutputStream(java.io.BufferedOutputStream)

Aggregations

DataGroup (uk.ac.babraham.SeqMonk.DataTypes.DataGroup)17 DataSet (uk.ac.babraham.SeqMonk.DataTypes.DataSet)16 DataStore (uk.ac.babraham.SeqMonk.DataTypes.DataStore)11 Vector (java.util.Vector)8 SeqMonkException (uk.ac.babraham.SeqMonk.SeqMonkException)6 JLabel (javax.swing.JLabel)5 ReplicateSet (uk.ac.babraham.SeqMonk.DataTypes.ReplicateSet)5 Probe (uk.ac.babraham.SeqMonk.DataTypes.Probes.Probe)4 GridBagConstraints (java.awt.GridBagConstraints)3 GridBagLayout (java.awt.GridBagLayout)3 JComboBox (javax.swing.JComboBox)3 JPanel (javax.swing.JPanel)3 AnnotationSet (uk.ac.babraham.SeqMonk.DataTypes.Genome.AnnotationSet)3 Chromosome (uk.ac.babraham.SeqMonk.DataTypes.Genome.Chromosome)3 PairedDataSet (uk.ac.babraham.SeqMonk.DataTypes.PairedDataSet)3 ProbeList (uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList)3 ActionEvent (java.awt.event.ActionEvent)2 IOException (java.io.IOException)2 CoreAnnotationSet (uk.ac.babraham.SeqMonk.DataTypes.Genome.CoreAnnotationSet)2 HiCDataStore (uk.ac.babraham.SeqMonk.DataTypes.HiCDataStore)2