use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList 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.Probes.ProbeList in project SeqMonk by s-andrews.
the class HeatmapMatrix method findCommonProbeListParent.
@SuppressWarnings({ "rawtypes", "unchecked" })
private ProbeList findCommonProbeListParent() {
if (probeLists.length == 1) {
return probeLists[0];
} else {
HashSet[] parents = new HashSet[probeLists.length - 1];
for (int i = 1; i < probeLists.length; i++) {
parents[i - 1] = new HashSet<ProbeList>();
ProbeList currentList = probeLists[i];
parents[i - 1].add(currentList);
while (!(currentList instanceof ProbeSet)) {
parents[i - 1].add(currentList.parent());
currentList = currentList.parent();
}
}
// Now we go through the first list to find the common parent
ProbeList firstList = probeLists[0];
boolean notFound = false;
while (true) {
notFound = false;
for (int i = 0; i < parents.length; i++) {
if (!parents[i].contains(firstList)) {
notFound = true;
}
}
if (notFound) {
firstList = firstList.parent();
} else {
return firstList;
}
}
}
}
use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class HeatmapMatrix method createProbeListsFromClusters.
public ProbeList createProbeListsFromClusters(int minClusterSize, int startIndex, int endIndex) {
if (cluster == null)
return null;
ClusterPair[] connectedClusters = cluster.getConnectedClusters(currentClusterRValue);
ProbeList commonList = findCommonProbeListParent();
ProbeList allClusterList = new ProbeList(commonList, "HiC Clusters", "HiC Clusters with R > " + commonList, null);
HashSet<Probe> allClusterProbes = new HashSet<Probe>();
// Now we need to work our way through the connected clusters
// to make the appropriate sub-lists
// Make up the same initial list of probes as before
Vector<Probe> originallyOrderedProbes = new Vector<Probe>();
for (int l = 0; l < probeLists.length; l++) {
Probe[] theseProbes = probeLists[l].getAllProbes();
for (int p = 0; p < theseProbes.length; p++) {
originallyOrderedProbes.add(theseProbes[p]);
}
}
int currentPosition = 0;
for (int subListIndex = 0; subListIndex < connectedClusters.length; subListIndex++) {
Integer[] indices = connectedClusters[subListIndex].getAllIndices();
currentPosition += indices.length;
if (currentPosition - indices.length < startIndex)
continue;
if (currentPosition > endIndex)
break;
// We may get rid of the list later if there are duplicates in it.
if (indices.length < minClusterSize)
continue;
Probe[] theseProbes = new Probe[indices.length];
for (int i = 0; i < theseProbes.length; i++) {
theseProbes[i] = originallyOrderedProbes.elementAt(indices[i]);
}
Arrays.sort(theseProbes);
// Now find the non-redundant count
int nonRedCount = 1;
for (int i = 1; i < theseProbes.length; i++) {
if (theseProbes[i] != theseProbes[i - 1]) {
nonRedCount++;
}
}
// There aren't enough different probes to keep this set.
if (nonRedCount < minClusterSize)
continue;
ProbeList thisList = new ProbeList(allClusterList, "Cluster " + (subListIndex + 1), "HiC cluster list number " + (subListIndex + 1), "R-value");
float rValue = connectedClusters[subListIndex].rValue();
thisList.addProbe(theseProbes[0], rValue);
if (!allClusterProbes.contains(theseProbes[0])) {
allClusterList.addProbe(theseProbes[0], null);
allClusterProbes.add(theseProbes[0]);
}
for (int i = 1; i < theseProbes.length; i++) {
if (theseProbes[i] == theseProbes[i - 1])
continue;
thisList.addProbe(theseProbes[i], rValue);
if (allClusterProbes.contains(theseProbes[i])) {
continue;
}
allClusterList.addProbe(theseProbes[i], null);
allClusterProbes.add(theseProbes[i]);
}
}
return allClusterList;
}
use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class HeatmapMatrix method createProbeListFromCurrentInteractions.
public ProbeList createProbeListFromCurrentInteractions() {
ProbeList commonList = findCommonProbeListParent();
// TODO: Get a better name
ProbeList allProbesList = new ProbeList(commonList, "Filtered HiC hits", "HiC hits" + commonList, null);
HashSet<Probe> allClusterProbes = new HashSet<Probe>();
// Work our way through the interactions to get the subset which are active
InteractionProbePair[] exportedInteractions = filteredInteractions();
for (int i = 0; i < exportedInteractions.length; i++) {
if (!allClusterProbes.contains(exportedInteractions[i].probe1())) {
allProbesList.addProbe(exportedInteractions[i].probe1(), null);
allClusterProbes.add(exportedInteractions[i].probe1());
}
if (!allClusterProbes.contains(exportedInteractions[i].probe2())) {
allProbesList.addProbe(exportedInteractions[i].probe2(), null);
allClusterProbes.add(exportedInteractions[i].probe2());
}
}
return allProbesList;
}
use of uk.ac.babraham.SeqMonk.DataTypes.Probes.ProbeList in project SeqMonk by s-andrews.
the class FilterOptionsDialog method progressComplete.
public void progressComplete(String command, Object result) {
ProbeList newList = (ProbeList) result;
filterButton.setEnabled(true);
// See if any probes actually passed
if (newList.getAllProbes().length == 0) {
// We need to remove this empty list.
newList.delete();
JOptionPane.showMessageDialog(this, "No probes matched the criteria set", "Info", JOptionPane.INFORMATION_MESSAGE);
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);
}
Aggregations