Skip to content

Commit

Permalink
augustus sanity check
Browse files Browse the repository at this point in the history
  • Loading branch information
endixk committed Oct 19, 2022
1 parent 9ebb6fa commit a86fed8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/envs/toolkit/ExecHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected void addArg(String val) {
argMap.put(val, "");
}

private String buildCmd() {
protected String buildCmd() {
String cmd = job;
for(String arg : args) {
cmd += " " + arg + argMap.get(arg);
Expand Down
1 change: 1 addition & 0 deletions src/module/ProfileModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@ public static void run(String[] args) {
if(!GenericConfig.FORCE) {
if(query.checkResultFileExistence() > 0) {
Prompt.print("Result file already exists. To overwrite, use --force option.");
query.deactivate();
continue;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/pipeline/ExceptionHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ExceptionHandler {
public static final int EXCEPTION = 0xF0;
public static final int UNEXPECTED_ERROR = 0xF1;
public static final int ERROR_WITH_MESSAGE = 0xF2;
public static final int FAILED_COMMAND = 0xF3;

public static final int UNKNOWN_MODULE = 0x00;
public static final int UNKNOWN_OPTION = 0x01;
Expand Down Expand Up @@ -66,6 +67,8 @@ public static void handle(int exception) {
System.out.println("Program terminated by an unexpected error."); break;
case ERROR_WITH_MESSAGE:
System.out.println(OBJ.toString()); break;
case FAILED_COMMAND:
System.out.println("Failed subcommand : " + ANSIHandler.wrapper(OBJ.toString(), 'B')); break;
case UNKNOWN_OPTION:
System.out.println("Unrecognized option given : " + OBJ.toString()); break;
case MISSING_ARGUMENT:
Expand Down
16 changes: 16 additions & 0 deletions src/wrapper/AugustusWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import envs.config.PathConfig;
import envs.toolkit.ExecHandler;
import envs.toolkit.Shell;
import pipeline.ExceptionHandler;

public class AugustusWrapper extends ExecHandler {
public AugustusWrapper() {
Expand All @@ -28,6 +29,15 @@ void setOutPath(String outPath) {
addArg(">", outPath);
}

private boolean sanityCheck(String outPath) {
String cmd = "head -1 " + outPath;
String[] raw = Shell.exec(cmd);

if(raw.length < 1) return false;
if(raw[0].contains("gff")) return true;
return false;
}

public static void runAugustus(String ctgPath, int pst, int ped, String prfl, String outPath) {
AugustusWrapper aug = new AugustusWrapper();
aug.setCfg();
Expand All @@ -37,6 +47,12 @@ public static void runAugustus(String ctgPath, int pst, int ped, String prfl, St
aug.setCtgPath(ctgPath);
aug.setOutPath(outPath);
aug.exec();

// augustus failure
if(!aug.sanityCheck(outPath)) {
ExceptionHandler.pass(aug.buildCmd());
ExceptionHandler.handle(ExceptionHandler.FAILED_COMMAND);
}
}

// solve dependency
Expand Down
16 changes: 16 additions & 0 deletions src/wrapper/FastBlockSearchWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import envs.config.PathConfig;
import envs.toolkit.ExecHandler;
import envs.toolkit.Shell;
import pipeline.ExceptionHandler;
import envs.toolkit.Prompt;

public class FastBlockSearchWrapper extends ExecHandler {
Expand All @@ -25,13 +26,28 @@ void setOutPath(String outPath) {
addArg("2>", "/dev/null");
}

private boolean sanityCheck(String outPath) {
String cmd = "head -1 " + outPath;
String[] raw = Shell.exec(cmd);

if(raw.length < 1) return false;
if(raw[0].contains("Hits")) return true;
return false;
}

public static void runFastBlockSearch(String seqPath, String famPath, String outPath) {
FastBlockSearchWrapper fbs = new FastBlockSearchWrapper();
fbs.setCutoff();
fbs.setSeqPath(seqPath);
fbs.setFamPath(famPath);
fbs.setOutPath(outPath);
fbs.exec();

// fastBlockSearch failure
if(!fbs.sanityCheck(outPath)) {
ExceptionHandler.pass(fbs.buildCmd());
ExceptionHandler.handle(ExceptionHandler.FAILED_COMMAND);
}
}

// solve dependency
Expand Down

0 comments on commit a86fed8

Please sign in to comment.