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();
}
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);
}
}
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();
}
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;
}
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);
}
}
}
Aggregations