Skip to content

Commit

Permalink
Speeding up importing big tree files
Browse files Browse the repository at this point in the history
  • Loading branch information
rambaut committed Jun 17, 2024
1 parent af24230 commit b7fb937
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 335 deletions.
325 changes: 0 additions & 325 deletions examples/TestXML/EmpiricalTrees/testEmpiricalTrees.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/dr/app/beauti/options/PartitionTreeModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public TreeAsDataType getTreeAsDataType() {
}

public boolean isUsingEmpiricalTrees() {
return treeAsDataType == TreeAsDataType.EMPRICAL_TREES;
return treePartitionData != null && treeAsDataType == TreeAsDataType.EMPRICAL_TREES;
}

public void setUsingExternalEmpiricalTreeFile(boolean isUsingExternalEmpiricalTreeFile) {
Expand Down
15 changes: 12 additions & 3 deletions src/dr/evolution/io/Importer.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,10 @@ public char read() throws IOException {
* Reads a line, skipping over any comments.
*/
public String readLine() throws IOException {
return readLine(false);
}

public String readLine(boolean ignoreComments) throws IOException {

StringBuffer line = new StringBuffer();

Expand All @@ -229,7 +233,7 @@ public String readLine() throws IOException {

while (ch != '\n' && ch != '\r') {

if (hasComments) {
if (!ignoreComments && hasComments) {
if (ch == lineComment) {
skipComments(ch);
break;
Expand Down Expand Up @@ -455,13 +459,18 @@ public String readToken() throws IOException {
return readToken("");
}

public String readToken(String delimiters) throws IOException {
return readToken(delimiters, false);
}

/**
* Reads a token stopping when any whitespace, a comment or when any character
* in delimiters is found. If the token begins with a quote char
* then all characters will be included in token until a matching
* quote is found (including whitespace or comments).
* @ignoreComments if true this will not skip comment but just add them to the token.
*/
public String readToken(String delimiters) throws IOException {
public String readToken(String delimiters, boolean ignoreComments) throws IOException {
int space = 0;
char ch, ch2, quoteChar = '\0';
boolean done = false, first = true, quoted = false, isSpace;
Expand Down Expand Up @@ -497,7 +506,7 @@ public String readToken(String delimiters) throws IOException {
quoteChar = ch;
first = false;
space = 0;
} else if ( ch == startComment || ch == lineComment ) {
} else if (!ignoreComments && (ch == startComment || ch == lineComment) ) {
skipComments(ch);
lastDelimiter = ' ';
done = true;
Expand Down
Loading

0 comments on commit b7fb937

Please sign in to comment.