Skip to content

Commit

Permalink
Updated the genome selector to show multiple annotation versions for the
Browse files Browse the repository at this point in the history
same assembly grouped together.  Relates to #46
  • Loading branch information
s-andrews committed Nov 1, 2017
1 parent b25a065 commit 916724d
Showing 1 changed file with 55 additions and 6 deletions.
61 changes: 55 additions & 6 deletions uk/ac/babraham/SeqMonk/Dialogs/GenomeSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Hashtable;
import java.util.Vector;

import javax.swing.JButton;
Expand All @@ -41,6 +42,8 @@
import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;

import org.apache.commons.math3.stat.descriptive.moment.VectorialCovariance;

import uk.ac.babraham.SeqMonk.SeqMonkApplication;
import uk.ac.babraham.SeqMonk.Displays.ManualGenomeBuilder.ManualGenomeBuilderDialog;
import uk.ac.babraham.SeqMonk.Preferences.SeqMonkPreferences;
Expand Down Expand Up @@ -113,16 +116,43 @@ public GenomeSelector (SeqMonkApplication application) {

if (assemblies == null) continue;

Arrays.sort(assemblies);

boolean foundAssembly = false;
Hashtable<String, Vector<File>> assemblySets = new Hashtable<String, Vector<File>>();

for (int j=0;j<assemblies.length;j++) {
if (assemblies[j].isDirectory()) {
genomeNode.add(new AssemblyNode(assemblies[j]));
foundAssembly = true;
String name = assemblies[j].getName();
name = name.replaceAll("_v\\d+$", "");

if (!assemblySets.containsKey(name)) {
assemblySets.put(name,new Vector<File>());
}

assemblySets.get(name).add(assemblies[j]);
}
}

String [] assemblySetNames = assemblySets.keySet().toArray(new String [0]);

Arrays.sort(assemblySetNames);

for (int j=0;j<assemblySetNames.length;j++) {

File [] localAssemblies = assemblySets.get(assemblySetNames[j]).toArray(new File[0]);

if (localAssemblies.length == 1) {
genomeNode.add(new AssemblyNode(localAssemblies[0]));
}
else {
AssemblySetNode setNode = new AssemblySetNode(assemblySetNames[j]);
genomeNode.add(setNode);


for (int k=0;k<localAssemblies.length;k++) {
setNode.add(new AssemblyNode(localAssemblies[k]));
}
}
}
if (foundAssembly) {
if (assemblySetNames.length > 0) {
if (genomes[i].getName().equals("Controls")) {
controlsRoot.add(genomeNode);
}
Expand Down Expand Up @@ -295,6 +325,25 @@ public void valueChanged(TreeSelectionEvent tse) {

}


/**
* The Class AssemblyNode.
*/
private class AssemblySetNode extends DefaultMutableTreeNode {


/**
* Instantiates a new assembly node.
*
* @param f the f
*/
public AssemblySetNode (String name) {
super(name);
}

}


/**
* The Class AssemblyNode.
*/
Expand Down

0 comments on commit 916724d

Please sign in to comment.