Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes for PATRIC build #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file modified bin/edu/vt/vbi/ci/pepr/tree/pipeline/PhyloPipeline.class
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public void setMuscleHostWorkingDir(String muscleHostWorkingDir) {
}

private void determineMusclePath() {
muscleHostMusclePath = ExecUtilities.getCommandPath("muscle");
muscleHostMusclePath = ExecUtilities.getCommandPath("muscle-3.6");
}

public void addMuscleOption(String opt) {
Expand Down
2 changes: 1 addition & 1 deletion src/edu/vt/vbi/ci/pepr/tree/pipeline/HMMSetEnhancer.java
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ private class HMMSearchRunner implements Runnable {
private String hmmFileName;
private TextFile[] resultHolder;
private HMMResult[][] hmmResultHolder;
boolean keepHMMSearchFiles = true;
boolean keepHMMSearchFiles = false;

public HMMSearchRunner(String hmmfileName, TextFile[] resultHolder,
HMMResult[][] hmmResultHolder) {
Expand Down
30 changes: 18 additions & 12 deletions src/edu/vt/vbi/ci/pepr/tree/pipeline/PhyloPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
*/
public class PhyloPipeline {

private static final int MINIMUM_GENOME_COUNT = 4;

private static Logger logger;
private static HashMap<String,String> commands;
Expand Down Expand Up @@ -254,6 +255,10 @@ public PhyloPipeline(String[] args) {
if(uniqueSpecies) {
homologySearchSequenceFiles =
filterOutDuplicateSpecies(homologySearchSequenceFiles);
if(homologySearchSequenceFiles.length < MINIMUM_GENOME_COUNT) {
System.out.println("There are not enough unique species to use the unique species filter, so all genomes will be used.");
homologySearchSequenceFiles = inputSequenceFiles;
}
Arrays.sort(homologySearchSequenceFiles);
} else if(uniqueGenus) {
homologySearchSequenceFiles =
Expand Down Expand Up @@ -525,22 +530,28 @@ private static String newickToPATRICJSON(String newickTree, String[] outgroupGen
String idOnlyNewick = newickTree;
BasicTree tree = new BasicTree(newickTree);
String[] leaves = tree.getLeaves();
ArrayList<String> idList = new ArrayList<String>(leaves.length);
HashMap<String,String> nameToId = new HashMap<String,String>();
HashSet<String> outgroup = new HashSet<String>();
for(String og: outgroupGenomes) {
String[] parts = og.split(delimiter);
outgroup.add(parts[nameIndex].replaceAll("_", " "));
}

JSONObject labelJSON = new JSONObject();
//verify that leaves are in <genome_name>@<genome_id> format
//extract genome name and genome id to make map
//replace leaves with just genome id
for(String leaf: leaves) {
if(leaf.contains(delimiter)) {
String[] parts = leaf.split(delimiter);
String name = parts[nameIndex].replaceAll("_", " ");
String id = parts[idIndex];
idOnlyNewick = idOnlyNewick.replaceFirst(leaf, parts[idIndex]);
nameToId.put(parts[nameIndex].replaceAll("_", " "), parts[idIndex]);
}
nameToId.put(name, id);
labelJSON.put(id,name);
idList.add(id);
}
}

JSONObject outgroupJSON = new JSONObject();
Expand All @@ -559,14 +570,7 @@ private static String newickToPATRICJSON(String newickTree, String[] outgroupGen

infoJSON.put("taxon_name", taxonName);
infoJSON.put("taxon_rank", taxonRank);

JSONObject labelJSON = new JSONObject();
names = nameToId.keySet().toArray(new String[0]);
Arrays.sort(names);
for(String name: names) {
String id = nameToId.get(name);
labelJSON.put(id,name);
}
infoJSON.put("ids", idList);

JSONObject fullJSON = new JSONObject();
fullJSON.put("info", infoJSON);
Expand Down Expand Up @@ -752,7 +756,7 @@ public static void setCommandPaths() {
logger.info("bin directory: " + binDirName);

String[] commands = new String[]{
"muscle",
"muscle-3.6",
"Gblocks",
"blastall",
"blat",
Expand All @@ -770,11 +774,13 @@ public static void setCommandPaths() {
"hmmsearch"
};

/*
for(int i = 0; i < commands.length; i++) {
String fullCommandPath = binDirName + commands[i];
logger.info("set path for '" + commands[i] + "' to '" + fullCommandPath + "'" );
System.setProperty(commands[i], fullCommandPath);
}
*/
}

private TextFile runMCL(TextFile hitPairFile, String inflation, int threads) {
Expand Down Expand Up @@ -1141,7 +1147,7 @@ private void checkForRequiredPrograms() {
"hmmbuild",
"hmmsearch",
"mcl",
"muscle",
"muscle-3.6",
"raxmlHPC",
"raxmlHPC-PTHREADS"
};
Expand Down
5 changes: 4 additions & 1 deletion src/edu/vt/vbi/ci/util/CommandResults.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ public class CommandResults {

private String[] stdout;
private String[] stderr;
private int rc;

public CommandResults(String[] stdout, String[] stderr) {
public CommandResults(String[] stdout, String[] stderr, int rc) {
this.stdout = stdout;
this.stderr = stderr;
this.rc = rc;
}
public int getRc() { return rc; }

public String[] getStdout() {
return stdout;
Expand Down
18 changes: 15 additions & 3 deletions src/edu/vt/vbi/ci/util/ExecUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public static CommandResults exec(String command) {
logger.info(command);
Process proc = Runtime.getRuntime().exec(command);
r = getResultFromProcess(proc);
logger.info(command + " has rc " + r.getRc() + "\n");
for (String s : r.getStderr())
{
logger.info(" " + s);
}
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
Expand Down Expand Up @@ -52,6 +57,12 @@ public static CommandResults exec(String[] command) {
e.printStackTrace();
}

if (r.getRc() != 0)
{
logger.warn("Error return " + r.getRc() + " from command " + command);
}


return r;
}

Expand Down Expand Up @@ -82,13 +93,14 @@ private static CommandResults getResultFromProcess(Process proc) throws Interrup

errorThread.join();
outThread.join();
r = new CommandResults(outReader.getLinesRead(),
errorRead.getLinesRead());

//call destroy() on process to free resources. The streams
//are not closed automatically, and may eventually
//accumulate and result in an "IOException: Too many open files"
proc.waitFor();
int rc = proc.waitFor();
r = new CommandResults(outReader.getLinesRead(),
errorRead.getLinesRead(), rc);

try {
proc.getErrorStream().close();
proc.getInputStream().close();
Expand Down