Skip to content

Commit

Permalink
Made Evaluator to also generate extended GO output tables
Browse files Browse the repository at this point in the history
  • Loading branch information
asishallab committed Jul 16, 2016
1 parent b25607b commit 7aa8e07
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/ahrd/controller/Evaluator.java
Expand Up @@ -9,6 +9,7 @@
import ahrd.model.Blast2GoAnnot;
import ahrd.model.Protein;
import ahrd.model.ReferenceDescription;
import ahrd.view.ExtendedGOAnnotationTableWriter;
import ahrd.view.OutputWriter;

public class Evaluator extends AHRD {
Expand All @@ -18,35 +19,28 @@ public Evaluator(String pathToInputYml) throws IOException {
}

public void setupReferences() throws IOException, MissingAccessionException {
List<String> fastaEntries = Protein.splitFasta(getSettings()
.getReferencesFasta());
List<String> fastaEntries = Protein.splitFasta(getSettings().getReferencesFasta());
for (String fastaEntry : fastaEntries) {
if (fastaEntry != null && !fastaEntry.trim().equals("")) {
ReferenceDescription rd = ReferenceDescription
.constructFromFastaEntry(fastaEntry.trim());
ReferenceDescription rd = ReferenceDescription.constructFromFastaEntry(fastaEntry.trim());
Protein p = getProteins().get(rd.getAccession());
if (p == null)
throw new MissingAccessionException(
"Could not find Protein for Accession '"
+ rd.getAccession() + "'");
"Could not find Protein for Accession '" + rd.getAccession() + "'");
p.getEvaluationScoreCalculator().setReferenceDescription(rd);
}
}
}

public void setupBlast2GoAnnots() throws IOException,
MissingAccessionException {
public void setupBlast2GoAnnots() throws IOException, MissingAccessionException {
if (getSettings().getPathToBlast2GoAnnotations() != null
&& !getSettings().getPathToBlast2GoAnnotations().equals("")) {
for (String blast2GoResultEntry : getSettings()
.getBlast2GoAnnotations()) {
Blast2GoAnnot b2ga = Blast2GoAnnot
.fromBlast2GoEntry(blast2GoResultEntry);
for (String blast2GoResultEntry : getSettings().getBlast2GoAnnotations()) {
Blast2GoAnnot b2ga = Blast2GoAnnot.fromBlast2GoEntry(blast2GoResultEntry);
Protein p = getProteins().get(b2ga.getAccession());
if (p == null)
throw new MissingAccessionException(
"Could not find Protein for Accession '"
+ b2ga.getAccession() + "'");
"Could not find Protein for Accession '" + b2ga.getAccession() + "'");
p.getEvaluationScoreCalculator().addBlast2GoAnnot(b2ga);
}
}
Expand All @@ -56,8 +50,7 @@ public void setupBlast2GoAnnots() throws IOException,
* @param args
*/
public static void main(String[] args) {
System.out
.println("Usage:\njava -Xmx2g -cp ahrd.jar ahrd.controller.Evaluator input.yml\n");
System.out.println("Usage:\njava -Xmx2g -cp ahrd.jar ahrd.controller.Evaluator input.yml\n");

try {
Evaluator evaluator = new Evaluator(args[0]);
Expand All @@ -80,8 +73,14 @@ public static void main(String[] args) {
// Generate Output:
OutputWriter ow = new OutputWriter(evaluator.getProteins().values());
ow.writeOutput();
System.out.println("Written output into:\n"
+ getSettings().getPathToOutput());
System.out.println("Written output into:\n" + getSettings().getPathToOutput());
// If requested, write extended Gene Ontology (GO) annotation table:
if (getSettings().generateExtendedGoResultTable()) {
ExtendedGOAnnotationTableWriter gw = new ExtendedGOAnnotationTableWriter(
evaluator.getProteins().values(), evaluator.getGoDB());
gw.writeOutput();
System.out.println("Wrote extended GO table.");
}
} catch (Exception e) {
System.err.println("We are sorry, an unexpected ERROR occurred:");
e.printStackTrace(System.err);
Expand Down Expand Up @@ -113,8 +112,7 @@ public void calculateEvaluationScores() {
*/
public void findHighestPossibleEvaluationScores() {
for (Protein prot : getProteins().values()) {
prot.getEvaluationScoreCalculator()
.findHighestPossibleEvaluationScore();
prot.getEvaluationScoreCalculator().findHighestPossibleEvaluationScore();
}
}

Expand Down

0 comments on commit 7aa8e07

Please sign in to comment.