From 80e848880d0d3b9c439722a5c6e71305ae9d6fda Mon Sep 17 00:00:00 2001 From: Lachlan Coin Date: Sun, 17 Feb 2019 22:50:45 +1000 Subject: [PATCH] fixing bugs in tree coloring code --- Makefile | 2 +- .../japsa/bio/phylo/CSSProcessCommand.java | 87 ++++--- src/main/java/japsa/bio/phylo/ColorTree.java | 34 --- src/main/java/japsa/bio/phylo/CommonTree.java | 11 +- src/main/java/japsa/bio/phylo/GetTaxonID.java | 74 +++--- src/main/java/japsa/bio/phylo/NCBITree.java | 230 +++++++++--------- 6 files changed, 209 insertions(+), 229 deletions(-) diff --git a/Makefile b/Makefile index a33a8689..3ba8fbc9 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ LIB_DIR=libs #List of external libraries ##EXT_LIBS=colloquial.jar commons-io-2.5.jar commons-math3-3.0.jar jhdf5.jar jhdfobj.jar htsjdk-2.10.1.jar guava-18.0.jar jcommon-1.0.23.jar jfreechart-1.0.19.jar JRIEngine.jar JRI.jar gs-core-1.3.jar gs-ui-1.3.jar gs-algo-1.3.jar javax.json-api-1.0.jar javax.json-1.0.4.jar slf4j-api-1.7.25.jar slf4j-simple-1.7.25.jar jfxrt.jar gson-2.3.jar -EXT_LIBS=colloquial.jar commons-io-2.5.jar commons-math3-3.0.jar jhdf5.jar jhdfobj.jar htsjdk-2.10.1.jar guava-18.0.jar jcommon-1.0.23.jar jfreechart-1.0.19.jar gs-core-1.3.jar gs-ui-1.3.jar gs-algo-1.3.jar javax.json-api-1.0.jar javax.json-1.0.4.jar slf4j-api-1.7.25.jar slf4j-simple-1.7.25.jar jfxrt.jar gson-2.3.jar +EXT_LIBS=pal1.5.1.1.jar mdsj.jar colloquial.jar commons-io-2.5.jar commons-math3-3.0.jar jhdf5.jar jhdfobj.jar htsjdk-2.10.1.jar guava-18.0.jar jcommon-1.0.23.jar jfreechart-1.0.19.jar gs-core-1.3.jar gs-ui-1.3.jar gs-algo-1.3.jar javax.json-api-1.0.jar javax.json-1.0.4.jar slf4j-api-1.7.25.jar slf4j-simple-1.7.25.jar jfxrt.jar gson-2.3.jar ########################################################################### ##What this scripts does: diff --git a/src/main/java/japsa/bio/phylo/CSSProcessCommand.java b/src/main/java/japsa/bio/phylo/CSSProcessCommand.java index e61dc17f..a979f89b 100644 --- a/src/main/java/japsa/bio/phylo/CSSProcessCommand.java +++ b/src/main/java/japsa/bio/phylo/CSSProcessCommand.java @@ -19,8 +19,17 @@ public class CSSProcessCommand { private static final Logger LOG = LoggerFactory.getLogger(CSSProcessCommand.class); public static void main(String[] args){ - //input files + + File resistant_gene_list = new File("resistant_genes_list.txt"); + File taxdir = new File("taxdump"); + + if(!taxdir.exists()) taxdir = new File("../taxdump"); + if(!taxdir.exists()){ + throw new RuntimeException("cannot find taxdump/ directory. Please make a symbolic link into the " + + "working directory, or into parent directory"); + + } File taxdump = new File("taxdump/names.dmp"); File nodesdmp= new File("taxdump/nodes.dmp"); File speciesIndex = new File("speciesIndex"); @@ -35,49 +44,64 @@ public static void main(String[] args){ File treeout = new File("commontree.txt.css"); File treeout_mod = new File("commontree.txt.css.mod"); - GetTaxonID gid = null; - NCBITree trees_species = null ; - AntibioticTree trees_drugs = null; + + //NCBITree trees_species = null ; + // AntibioticTree trees_drugs = null; /*Step 1 read resistance gene tree and color it */ if(resistant_gene_list.exists() && ! resistance_treeout.exists()){ - trees_drugs = makeResistanceTree(resistant_gene_list, resistance_treeout); + makeResistanceTree(resistant_gene_list, resistance_treeout); } + + + + try{ + + GetTaxonID gid = new GetTaxonID(taxdump, nodesdmp); //Step2 get taxon information if(taxdump.exists() && speciesIndex.exists() && !taxon_file.exists()){ LOG.info("getting taxon information"); - gid = getTaxaForSpecies(taxdump, speciesIndex, taxon_file); + getTaxaForSpecies(gid, speciesIndex, taxon_file); } // if(true) return; /*step -3 read tree */ - if(taxdump.exists() && taxon_file.exists() && !treein.exists()){ + if( taxon_file.exists() && !treein.exists()){ LOG.info("making tree"); - trees_species = readTaxaTree(gid, nodesdmp, taxon_file, taxdump, treein); + + readTaxaTree(gid,taxon_file, treein); } /*Step 4 color species tree */ if(treein.exists() && !treeout.exists()){ LOG.info("adding CSS to tree"); - addCSSToTree(trees_species, treein, treeout); + addCSSToTree(treein, treeout); } /*Step 5 place the lines from speciesIndex in the tree and add color */ if(treeout.exists() && ! treeout_mod.exists()){ LOG.info("adding extra nodes from speciesIndex"); - trees_species = addExtraNodesFromSpeciesIndex(trees_species, treeout, taxon_file, taxdump, speciesIndex, treeout_mod); + addExtraNodesFromSpeciesIndex( gid, treeout, taxon_file, taxdump, speciesIndex, treeout_mod); + } + + }catch(Exception exc){ + exc.printStackTrace(); } + + + } + + public static void test(String[] args){ + File treeout_mod = new File("commontree.txt.css.mod"); + File resistance_treeout = new File("resistancetree.txt.css"); + /*Step 6 testing */ if(treeout_mod.exists()){ String totest = "NC_004355.1:AJ717516.1:NC_023018.1:Homo sapiens:Capnocytophaga canimorsus:Staphylococcus aureus:NC_023018.1:NC_002645.1"; - LOG.info("testing"); - test(treeout_mod, totest.split(":")); - - } if(resistance_treeout.exists()){ @@ -85,13 +109,13 @@ public static void main(String[] args){ String totest = "blaCTX:tetX"; test(resistance_treeout, totest.split(":")); } + } - public static GetTaxonID getTaxaForSpecies(File taxdump, File speciesIndex, File output){ - GetTaxonID gid = null; + public static GetTaxonID getTaxaForSpecies(GetTaxonID gid, File speciesIndex, File output){ + //GetTaxonID gid = null; try{ - File taxaToInclude = null; - gid = new GetTaxonID(taxaToInclude, taxdump); + if(true){ // gid.processGenBank(assembly_summary_inputs); gid.process(speciesIndex); @@ -103,13 +127,15 @@ public static GetTaxonID getTaxaForSpecies(File taxdump, File speciesIndex, File return gid; } - public static NCBITree readTaxaTree(GetTaxonID gid, File nodesdmp, File taxonid, File taxdump, File treeout){ + public static NCBITree readTaxaTree(GetTaxonID gid, File taxonFile ,File treeout){ NCBITree trees = null; try{ - trees= - gid == null ? new NCBITree(nodesdmp, taxonid, taxdump) : new NCBITree(nodesdmp, gid); - - + gid.read(taxonFile); // this tells which nodes to include in tree + boolean cts = gid.taxon_set.contains("191289"); + //System.err.println(gid.taxon_set.size()); + //System.err.println(gid.taxa2Sci.get("191289")); + trees = new NCBITree(gid); + trees.print(treeout); }catch(Exception exc){ @@ -119,11 +145,11 @@ public static NCBITree readTaxaTree(GetTaxonID gid, File nodesdmp, File taxonid, return trees; } - public static CommonTree addCSSToTree(CommonTree trees1, File treein, File treeout){ + public static CommonTree addCSSToTree( File treein, File treeout){ CommonTree trees = null; try{ trees = //trees1==null ? - new NCBITree(treein, null, null); //need to re-read + new NCBITree(treein, false); //need to re-read //: trees1; Tree[] tree = trees.getTrees(); for(int i=0; i1000) continue; - ColorTree ct = new ColorTree(tree[i]); - ct.color(); - } - trees.print(new File(f.getName()+".css")); - - }catch(Exception exc){ - exc.printStackTrace(); - - } -} -public void printSlug(String out) throws Exception{ - PrintWriter pw = new PrintWriter(new FileWriter(out)); - /* - for(Iterator it = this.colors.keySet().iterator(); it.hasNext();){ - String key = it.next(); - String value = colors.get(key); - pw.println(key+"\t"+value); - - }*/ - pw.close(); -} static double rand =0; diff --git a/src/main/java/japsa/bio/phylo/CommonTree.java b/src/main/java/japsa/bio/phylo/CommonTree.java index 5646f42b..6b15fe65 100644 --- a/src/main/java/japsa/bio/phylo/CommonTree.java +++ b/src/main/java/japsa/bio/phylo/CommonTree.java @@ -35,23 +35,24 @@ public void print(File out) throws IOException{ // PrintWriter pw = new PrintWriter(new FileWriter(out)); for(int i=0; i n = NodeUtils.preOrderIterator(roots.get(i)); - inner: for(int j=0; n.hasNext() ;j++){ - // System.err.println(i+" "+j); + inner: while(n.hasNext()){ Node node = n.next(); + Identifier id = node.getIdentifier(); String nme =id.getName(); - + //if(nme.indexOf("unclassified ssRNA")>=0){ + // System.err.println("h"); + //} Integer level = ((Integer)id.getAttribute("level")).intValue(); String hex = ((String)id.getAttribute("css")); - // String hex = ((String)id.getAttribute("level")); String alias = ((String)id.getAttribute("alias")); String alias1 = ((String)id.getAttribute("alias1")); String prefix = ((String)id.getAttribute("prefix")); Integer taxon = ((Integer)id.getAttribute("taxon")); double height = node.getNodeHeight(); - //System.err pw.print(prefix+nme); if(hex!=null) pw.print("\tcss="+hex); if(alias!=null) pw.print("\talias="+alias); diff --git a/src/main/java/japsa/bio/phylo/GetTaxonID.java b/src/main/java/japsa/bio/phylo/GetTaxonID.java index 01fbe035..65749d9b 100644 --- a/src/main/java/japsa/bio/phylo/GetTaxonID.java +++ b/src/main/java/japsa/bio/phylo/GetTaxonID.java @@ -16,32 +16,32 @@ import java.util.zip.GZIPInputStream; /** extract taxon ids matching speciesIndex from a list of assembly summary files */ public class GetTaxonID { - Set taxon_set = new HashSet(); - Map name2Taxa = new HashMap(); - Map name2Taxa4 = new HashMap(); - Map name2Taxa3 = new HashMap(); - Map name2Taxa2 = new HashMap(); + Set taxon_set = new HashSet(); + Map name2Taxa = new HashMap(); + Map name2Taxa4 = new HashMap(); + Map name2Taxa3 = new HashMap(); + Map name2Taxa2 = new HashMap(); - Map taxa2Sci = new HashMap(); + Map taxa2Sci = new HashMap(); public GetTaxonID(){ } public String getSciName(final String specName){ - String taxa = getTaxa(specName); + Integer taxa = getTaxa(specName); if(taxa!=null){ return taxa2Sci.get(taxa); } else return null; } - public String getTaxa(final String specName){ + public Integer getTaxa(final String specName){ String slug = Slug.toSlug(specName, ""); String slug4 = Slug.toSlug(specName, 4,""); String slug3 = Slug.toSlug(specName, 3,""); String slug2 = Slug.toSlug(specName, 2,""); - String taxa = this.name2Taxa.get(slug); + Integer taxa = this.name2Taxa.get(slug); if(taxa==null) taxa = name2Taxa4.get(slug4); if(taxa==null) taxa = name2Taxa3.get(slug3); if(taxa==null) taxa = name2Taxa2.get(slug2); @@ -51,7 +51,7 @@ public String getTaxa(final String specName){ // err.println(specName+"->"+slug1+"->"+slug2+"->"+slug3+"->"+taxa); return taxa; } - void putTaxa(String nme, String taxa){ + void putTaxa(String nme, Integer taxa){ String slug = Slug.toSlug(nme, ""); String slug4 = Slug.toSlug(nme, 4,""); @@ -61,45 +61,39 @@ void putTaxa(String nme, String taxa){ name2Taxa4.put(slug4, taxa); name2Taxa3.put(slug3, taxa); name2Taxa2.put(slug2, taxa); - if(nme.indexOf("229E-related")>=0){ - System.err.println(slug); - System.err.println('h'); - } + } PrintWriter err; - public Map nodeToParent = new HashMap(); + public Map nodeToParent = new HashMap(); public void addNodeDmp(File file) throws IOException{ BufferedReader br = getBR(file); String st = ""; while((st = br.readLine())!=null){ String[] str = st.split("\\|"); - - nodeToParent.put(str[0].trim(), str[1].trim()); + nodeToParent.put(Integer.parseInt(str[0].trim()), Integer.parseInt(str[1].trim())); } br.close(); } - - - public GetTaxonID(File file, File names_dmp) throws IOException{ - // err = new PrintWriter(new FileWriter(new File("err.txt"))); - if(file!=null && file.exists()){ - BufferedReader br = getBR(file); - String st = ""; - while((st = br.readLine())!=null){ - taxon_set.add(st.split("\\s+")[0]); - } - br.close(); + public void read(File taxon_set) throws IOException{ + BufferedReader br1 = getBR(taxon_set); + String st1; + while((st1 = br1.readLine())!=null){ + this.taxon_set.add(Integer.parseInt(st1.split("\t")[0])); } - if(names_dmp.exists()){ + br1.close(); + } + + public GetTaxonID( File names_dmp, File node_dmp) throws IOException{ + BufferedReader br = getBR(names_dmp); String st = ""; while((st = br.readLine())!=null){ String[] str = st.split("\t"); - String taxa = str[0]; + Integer taxa = Integer.parseInt(str[0]); //if(taxon_set.contains(taxa)){ String nme = str[2];; String type = str[6]; @@ -112,27 +106,19 @@ public GetTaxonID(File file, File names_dmp) throws IOException{ } br.close(); - } + + this.addNodeDmp(node_dmp); // TODO Auto-generated constructor stub } public void print(File out) throws IOException{ PrintWriter pw = new PrintWriter(new FileWriter(out)); - for(Iterator it = taxon_set.iterator(); it.hasNext();){ + for(Iterator it = taxon_set.iterator(); it.hasNext();){ pw.println(it.next()); } pw.close(); } -public static void main(String[] args){ - try{ - GetTaxonID gid = new GetTaxonID(new File("taxonid"), new File("taxdump/names.dmp")); - gid.process(new File("speciesIndex")); - gid.print(new File("taxonid.new")); - - }catch(Exception exc){ - exc.printStackTrace(); - } - } + static BufferedReader getBR(File file)throws IOException{ BufferedReader br; @@ -149,7 +135,7 @@ public void process(File file)throws IOException { String st; while((st = br.readLine())!=null){ String[] str = st.split("\\s+"); - String taxa = this.processAlias(str, st); + Integer taxa = this.processAlias(str, st); if(taxa!=null) { this.taxon_set.add(taxa); @@ -172,7 +158,7 @@ public void process(File file)throws IOException { } } - String processAlias(String[] str, String st){ + Integer processAlias(String[] str, String st){ String alias1 = collapse(str, 1); /* int compg = alias1.indexOf(", complete genome"); if(compg>=0){ diff --git a/src/main/java/japsa/bio/phylo/NCBITree.java b/src/main/java/japsa/bio/phylo/NCBITree.java index 914c18ba..0bf4f58d 100644 --- a/src/main/java/japsa/bio/phylo/NCBITree.java +++ b/src/main/java/japsa/bio/phylo/NCBITree.java @@ -38,30 +38,8 @@ public class NCBITree extends CommonTree { GetTaxonID gid = null; - public static void main(String[] args){ - try{ - NCBITree t = new NCBITree(new File(args[0]), null, null);//, new File(args[1])); - - t.gid = new GetTaxonID(new File("taxonid"), new File("taxdump/names.dmp")); - - t.addSpeciesIndex(new File(args[1])); - t.gid.err.close(); - System.err.println("here"); - String[][] taxa = t.getTaxonomy(t.tree[0].getExternalNode(0).getIdentifier().getName()); - System.err.println(Arrays.asList(taxa[0])); - System.err.println(Arrays.asList(taxa[1])); - t.print(new File(args[0]+".mod")); - // NCBITree t1 = new NCBITree("commontree.txt.out1"); - // t1.print(new File("commontree.txt.out2"));*/ - // System.err.println(t.tree.getExternalNodeCount()); - }catch(Exception exc){ - exc.printStackTrace(); - } - } - public static CommonTree read(File f) throws IOException{ - return new NCBITree(f); - } + @@ -71,18 +49,7 @@ public static CommonTree read(File f) throws IOException{ - public static Tree[] readTree(File f) throws IOException{ - NCBITree t = new NCBITree(f); - return t.tree; - } - - public static NCBITree readTree(File f, File speciesIndex) throws IOException{ - NCBITree t = new NCBITree(f); - if(speciesIndex!=null){ - t.addSpeciesIndex(speciesIndex); - } - return t; - } + /* private void putSlug1(String str, TreePos tp){ String slug = Slug1.toSlug1(str); @@ -95,55 +62,46 @@ private TreePos getSlug1(String str){ return this.slugToPos.get(Slug1.toSlug1(str)); }*/ - public Node getNode(String specName, String taxa) { - Node n = slugToNode.get(slug(specName, false)); - if(n==null) { - n = slugToNode1.get(Integer.parseInt(taxa)); + public Integer getTaxa(String sciname){ + return gid.getTaxa(sciname); + } + + public Node getNode(String sciName) { + if(useTaxaAsSlug){ + return slugToNode1.get(getTaxa(sciName)); + }else{ + return slugToNode.get(sciName); } - return n; } - @Override - public Node getNode(String specName) { - Node n; - // String specName1 = null; - /* if(gid!=null){ - specName1 = this.gid.getSciName(specName); - if(specName1!=null){ - specName = specName1; - } - }*/ - n = slugToNode.get(slug(specName, false)); +public Node getNode(Integer taxa) { + + Node n = slugToNode1.get(taxa); + return n; - } - - public Node getSlug1( String alias1){ - Node n2 = getNode(alias1); - if(n2==null){ - return slugToNode.get("unclassified"); - } - return n2; } + + /*str is a line from species index */ private void updateTree(String st, int lineno, double bl, PrintWriter missing){ String[] str = st.split("\\s+"); // String specName = str[0]; - String taxa = gid.processAlias(str,st); + Integer taxa = gid.processAlias(str,st); String alias1 = gid.collapse(str, 1); String sciname = taxa==null ? null : gid.taxa2Sci.get(taxa); Node n; if(sciname==null && taxa==null) { n = this.unclassified; Node n1 = this.createFromSpeciesFile(str,alias1, n, lineno, bl); - - System.err.println(n1.getIdentifier().getAttribute("level")); - System.err.println(n1.getIdentifier().getAttribute("prefix")); - System.err.println(n1.getIdentifier()); + // System.err.println(n1.getIdentifier().getAttribute("level")); + //System.err.println(n1.getIdentifier().getAttribute("prefix")); + //System.err.println(n1.getIdentifier()); } else{ - n = getNode(sciname, taxa); + n = this.slugToNode1.get(taxa);//getNode( taxa); + this.createFromSpeciesFile(str,alias1, n, lineno, bl); //System.err.println(n.getIdentifier().getName()); } @@ -195,7 +153,7 @@ public String toString(){ int node_index; } - private Map slugToNode = new HashMap(); + //private Map slugToNode = new HashMap(); @@ -209,6 +167,7 @@ private int getLevel(String line){ /*int a = nextLine.indexOf('-')+1; int b = nextLine.indexOf('+')+1; return Math.max(a, b);*/ + if(true) return line.indexOf("+-"); int level; Matcher matcher = plusminus.matcher(line); if(matcher.find()){ @@ -295,43 +254,62 @@ private String slug(String name, boolean shortslug){ } else return Slug.toSlug(name, slug_sep); } - Map slugToNode1 = new HashMap(); + + final boolean useTaxaAsSlug; + Map slugToNode = new HashMap(); + Map slugToNode1 = new HashMap(); - public boolean putSlug1( Node n){ - String name = n.getIdentifier().getName(); + public void putSlug1( Node n){ + + if(useTaxaAsSlug){ Integer taxon = (Integer) n.getIdentifier().getAttribute("taxon"); - boolean contains; - String slug = slug(name, false); - contains = slugToNode.containsKey(slug); - if(!contains) slugToNode.put(slug, n); - if(taxon !=null) { - slugToNode1.put(taxon, n); - if(taxon.intValue()==1739614){ - System.err.println("h"); - } + boolean contains = slugToNode1.containsKey(taxon); + if(!contains) { + slugToNode1.put(taxon, n); + } + }else{ + String name = n.getIdentifier().getName(); + boolean contains = slugToNode.containsKey(name); + if(!contains) { + slugToNode.put(name, n); + } } - return contains; } - private Node make(String line_, Node child, Integer taxon){ - Node n = slugToNode.get(slug(line_, false)); + private Node make( Integer taxon, Node child){ + String sci = gid.taxa2Sci.get(taxon); + Node n = getNode(taxon); if(n==null) { - n = new SimpleNode(line_, 0.1); + n = new SimpleNode(sci, 0.1); n.getIdentifier().setAttribute("taxon", taxon); putSlug1(n); } if(child!=null){ + // String name = child.getIdentifier().getName(); + //if(name.indexOf("Sclerophthora macrospora virus A")>=0){ + // System.err.println("h"); + //} n.addChild(child); } return n; } - +PrintWriter err; + + + + private Node make(String line_, int level, Node parent){ + String[] lines = line_.split("\t"); String line = lines[0]; String name = line; + err.println(name);err.flush(); String prefix = ""; + // if(line_.indexOf("Sclerophthora macrospora virus A")>=0){ + // System.err.println("h"); + // } + if(level>=0) { name = line.substring(level, line.length()); prefix = line.substring(0,level); @@ -342,29 +320,25 @@ private Node make(String line_, int level, Node parent){ name = name.substring(pm_ind+2); } - /*String trimmed = name.trim(); - int ind1 = name.indexOf(trimmed); - if(ind1>=0){ - prefix = prefix+name.substring(0, ind1); - name = trimmed; - } - if(prefix.indexOf("+-")<0) { - prefix = prefix+"+-"; - }*/ - /*if(gid!=null){ - //makes sure we use scientific name - String name1 = this.gid.getName(name); - if(name1!=null) name = name1; - }*/ Node n = new SimpleNode(name, 0.1); n.getIdentifier().setAttribute("level",level); n.getIdentifier().setAttribute("prefix",prefix); + Integer taxonvalue = null; for(int i=1; i=0 && gid!=null){ - gid.addNodeDmp(file); - System.err.println(gid.taxon_set.size()); - for(Iterator it = gid.taxon_set.iterator();it.hasNext();){ - String nxt = it.next(); - String parent= gid.nodeToParent.get(nxt); - Node n = make(gid.taxa2Sci.get(nxt), null, Integer.parseInt(nxt)); + + for(Iterator it = gid.taxon_set.iterator();it.hasNext();){ + Integer nxt = it.next(); + Integer parent= gid.nodeToParent.get(nxt); + Node n = make( nxt, null); Listl = new ArrayList(); l.add(n); inner: while(nxt!=null){ - String nextparent = gid.nodeToParent.get(parent); - if(parent==nxt) parent = null; + Integer nextparent = gid.nodeToParent.get(parent); + if(parent.equals(nxt)) parent = null; if(parent!=null){ - Node p = make(gid.taxa2Sci.get(parent), n, Integer.parseInt(parent)); + Node p = make(parent, n); l.add(p); n = p; } @@ -428,16 +401,36 @@ public NCBITree(File file, GetTaxonID gid) throws IOException { id.setAttribute("prefix", prefix); } } + Integer i0= (Integer) l.get(0).getIdentifier().getAttribute("taxon"); + //System.err.println(i0);; + //System.err.println(l.get(0).getIdentifier()); if(!roots.contains(n) ){ - System.err.println("new root "+n.getIdentifier());; + //System.err.println("new root "+n.getIdentifier());; roots.add(n); } + if(i0!=null){ + /* if(i0.equals(new Integer(191289))){ + // Node n1 = this.slugToNode.get(l.get(0).getIdentifier().getName()); + Node n2 = this.slugToNode1.get(i0); + for(int i=0; i name2Taxa= new HashMap(); + +public NCBITree(File file, boolean useTaxaAsAsslug) throws IOException { // this(f, null); + this.useTaxaAsSlug = useTaxaAsAsslug; + err= new PrintWriter(new FileWriter(new File("error.txt"))); BufferedReader br; if(file.getName().endsWith(".gz")){ br = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream(file)))); @@ -468,6 +461,9 @@ public NCBITree(File file) throws IOException { parentlevel =0; inner: while((nextLine = br.readLine())!=null){ nextLines = nextLine.split("\t"); + // if(nextLine.indexOf("Sclerophthora macrospora virus A")>=0){ + // System.err.println("h"); + // } if(nextLine.startsWith("--")){ nextLine=br.readLine(); nextLines = nextLine==null ? null : nextLine.split("\t"); @@ -495,7 +491,9 @@ public NCBITree(File file) throws IOException { } br.close(); - + if(err!=null){ + err.close(); + } @@ -516,7 +514,7 @@ public void makeTrees(){ System.err.println("making trees"); this.tree = new Tree[roots.size()]; System.err.println(tree.length); - System.err.println(this.slugToNode.size()); + // System.err.println(this.slugToNode.size()); for(int i=0; i