private boolean HasBootstrap = false;
private boolean HasDistances = false;
private boolean RootHasDistance = false;
+
private String ErrorStringrange(String Error, String Er, int r, int p, String s) {
return ((Error==null) ? "" : Error)
+ Er +
super(inFile, type);
}
+ // File IO Flags
+ boolean ReplaceUnderscores = false;
public void parse() throws IOException
{
}
root = new SequenceNode();
+ SequenceNode realroot = null;
SequenceNode c = root;
+
int d = -1;
int cp = 0;
int flen = nf.length();
+
String Error = null;
String nodename = null;
- float distance=-99999;
- int bootstrap=-99999;
+
+ float DefDistance = (float) 0.00001; // @param Default distance for a node - very very small
+ int DefBootstrap = 0; // @param Default bootstrap for a node
+
+ float distance=DefDistance;
+ int bootstrap=DefBootstrap;
+
boolean ascending = false; // flag indicating that we are leaving the current node
+
com.stevesoft.pat.Regex majorsyms = new com.stevesoft.pat.Regex("[(\\['),;]");
+
while (majorsyms.searchFrom(nf, cp) && Error==null) {
int fcp = majorsyms.matchedFrom();
switch (nf.charAt(fcp)) {
d++;
if (c.right() == null)
{
- c.setRight(new SequenceNode(null, c, 0, null));
+ c.setRight(new SequenceNode(null, c, null, DefDistance, DefBootstrap, false));
c = (SequenceNode) c.right();
}
else
tmpn.SetChildren(c.left(), c.right());
c.setRight(tmpn);
}
- c.setLeft(new SequenceNode(null, c, 0, null));
+ c.setLeft(new SequenceNode(null, c, null, DefDistance, DefBootstrap, false));
c = (SequenceNode) c.left();
}
+ if (realroot==null) {
+ realroot = c;
+ }
nodename = null;
- distance = -99999;
- bootstrap = -99999;
+ distance = DefDistance;
+ bootstrap = DefBootstrap;
cp = fcp + 1;
break;
{
if (nodename == null)
{
- nodename = uqnodename.stringMatched(1).replace('_', ' ');
+ if (ReplaceUnderscores) {
+ nodename = uqnodename.stringMatched(1).replace('_', ' ');
+ } else {
+ nodename = uqnodename.stringMatched(1);
+ }
}
else
{
cp + nbootstrap.matchedFrom(), nf);
}
}
-
+ boolean nodehasdistance=false;
if (ndist.search(fstring))
{
try
{
distance = (new Float(ndist.stringMatched(1))).floatValue();
HasDistances = true;
- if (c.parent()==root) {
- RootHasDistance = true;
- }
+ nodehasdistance = true;
}
catch (Exception e)
{
c.setName(nodename);
c.dist = (HasDistances) ? distance : 0;
c.setBootstrap((HasBootstrap) ? bootstrap : 0);
+ if (c==realroot) {
+ RootHasDistance = nodehasdistance; // JBPNote This is really UGLY!!!
+ }
}
else
{
// Find a place to put the leaf
- SequenceNode newnode = new SequenceNode(null, c,
- (HasDistances) ? distance : 0,
- nodename);
-
- newnode.setBootstrap(HasBootstrap ? bootstrap : 0);
+ SequenceNode newnode =
+ new SequenceNode(null, c,
+ nodename,
+ (HasDistances) ? distance : DefDistance,
+ (HasBootstrap) ? bootstrap : DefBootstrap,
+ false);
if (c.right() == null)
{
}
// Reset new node properties to obvious fakes
nodename = null;
- distance = -99999;
- bootstrap = -99999;
+ distance = DefDistance;
+ bootstrap = DefBootstrap;
cp=fcp+1;
}
}
root = (SequenceNode) root.right().detach(); // remove the imaginary root.
+ if (!RootHasDistance) {
+ root.dist = 0;
+ }
+
}
public NewickFile(SequenceNode newtree) {
}
catch (java.io.IOException e)
{
- System.out.println("Exception\n" + e);
+ System.err.println("Exception\n" + e);
e.printStackTrace();
}
}