Skip to content

Commit

Permalink
make sure annotations from experiments are using non-obsolete terms
Browse files Browse the repository at this point in the history
sped up sorting of matrix term-column headings

restored older macify
  • Loading branch information
selewis committed Sep 15, 2016
1 parent 85bba9e commit b908495
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 162 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>org.simplericity.macify</groupId>
<groupId>macify</groupId>
<artifactId>macify</artifactId>
<version>1.6</version>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.bbop</groupId>
Expand Down
2 changes: 1 addition & 1 deletion resources/org/paint/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.23
v2.24
27 changes: 24 additions & 3 deletions src/org/paint/gui/matrix/AnnotMatrixModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,36 @@ private void sortTerms(List<Bioentity> nodes, List<String> temp_list) {
* Then sort by the number of genes annotated to each term
* The more genes annotated the higher in the list the term will be
*/
Collections.sort(cellular_list, new TermCountComparator(nodes));
Collections.sort(temp_list, new TermCountComparator(nodes));
SortByCount(nodes, cellular_list);
SortByCount(nodes, temp_list);

/*
* But then insert the related terms immediately after their child
* But then insert the related terms immediately afterwards
*/
boolean odd_column = true;
odd_column = groupParentTerms(cellular_list, odd_column);
groupParentTerms(temp_list, odd_column);
}

private void SortByCount(List<Bioentity> nodes, List<String> terms) {
Map<String, List<Bioentity>> term2node = new HashMap<>();
for (Bioentity node : nodes) {
for (String term : terms) {
GeneAnnotation assoc = AnnotationUtil.isAnnotatedToTerm(node.getAnnotations(), term);
if (assoc != null && AnnotationUtil.isExpAnnotation(assoc)) {
List<Bioentity> annotated_nodes = term2node.get(term);
if (annotated_nodes == null) {
annotated_nodes = new ArrayList<Bioentity>();
term2node.put(term, annotated_nodes);
}
if (!annotated_nodes.contains(node)) {
annotated_nodes.add(node);
}
}
}
}
Collections.sort(terms, new TermCountComparator(term2node));
}

private boolean groupParentTerms(List<String> orig_termlist, boolean odd_column) {
while (orig_termlist.size() > 0) {
Expand Down
31 changes: 15 additions & 16 deletions src/org/paint/gui/matrix/TermCountComparator.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.paint.gui.matrix;

import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.bbop.phylo.annotate.AnnotationUtil;
import org.bbop.phylo.util.OWLutil;
import org.paint.displaymodel.DisplayBioentity;

import owltools.gaf.Bioentity;
import owltools.gaf.GeneAnnotation;
Expand All @@ -17,24 +17,23 @@ public class TermCountComparator implements Comparator<String> {
private static final int GREATER_THAN = 1;
private static final int EQUAL_TO = 0;

private List<Bioentity> nodes;
public TermCountComparator (List<Bioentity> nodes2) {
this.nodes = nodes2;
private Map<String, List<Bioentity>> term2nodes;

public TermCountComparator (Map<String, List<Bioentity>> term2nodes) {
this.term2nodes = term2nodes;
}

public int compare(String term_a, String term_b) {
int count_a = 0;
int count_b = 0;

if (nodes != null) {
for (Bioentity node : nodes) {
GeneAnnotation assoc_a = AnnotationUtil.isAnnotatedToTerm(node.getAnnotations(), term_a);
GeneAnnotation assoc_b = AnnotationUtil.isAnnotatedToTerm(node.getAnnotations(), term_b);
count_a += assoc_a != null && AnnotationUtil.isExpAnnotation(assoc_a) ? 1 : 0;
count_b += assoc_b != null && AnnotationUtil.isExpAnnotation(assoc_b) ? 1 : 0;
}
}

if (term2nodes.get(term_a) != null) {
count_a = term2nodes.get(term_a).size();
}
if (term2nodes.get(term_b) != null) {
count_b = term2nodes.get(term_b).size();
}

if (count_b > count_a)
return GREATER_THAN;
else if (count_b < count_a)
Expand Down
2 changes: 1 addition & 1 deletion src/org/paint/gui/menu/TreeMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void actionPerformed(ActionEvent e) {
case TREE_COLLAPSE_NONEXP_NODES:
PaintConfig.inst().collapse_no_exp = ((JCheckBoxMenuItem) e.getSource()).isSelected();
if (PaintConfig.inst().collapse_no_exp) {
tree.collapseNonExperimental(true);
tree.collapseNonExperimental();
} else {
tree.expandAllNodes();
}
Expand Down
31 changes: 0 additions & 31 deletions src/org/paint/gui/tracking/EvidencePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -296,37 +296,6 @@ public void run() {
}
}

// private class CommentThread extends Thread {
// private JTextArea text_area;
// private String comment;
//
// public CommentThread (JTextArea text_area) {
// this.text_area = text_area;
// comment = getLoggedComment();
// }
//
// public void run() {
// if (SwingUtilities.isEventDispatchThread()) {
// text_area.setText(comment);
// } else {
// try {
//// SwingUtilities.invokeAndWait(new Runnable() {
// while (true) {
//// public void run() {
// comment = text_area.getText();
// Logger.updateNotes(comment);
// Thread.sleep(1000);
//// };
// }
// } catch (InterruptedException ex) {
// log.error(ex.toString());
//// } catch (InvocationTargetException ex) {
//// log.error(ex.toString());
// }
// }
// }
// }
//
@Override
public void newFamilyData(FamilyChangeEvent e) {
comment_set = false;
Expand Down
Loading

0 comments on commit b908495

Please sign in to comment.