From 0d8eb4b63551b6f61dc30294409dacc7dee14095 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Mon, 30 Sep 2013 14:29:33 +0100 Subject: [PATCH] Bug Fixg: testing RNAalifold jobs have been considered as real ones --- .../compbio/stat/collector/InputFilter.java | 36 +++++++++++++++++++- webservices/compbio/ws/client/WSTester.java | 6 ++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/webservices/compbio/stat/collector/InputFilter.java b/webservices/compbio/stat/collector/InputFilter.java index 03466fe..3b2f45f 100644 --- a/webservices/compbio/stat/collector/InputFilter.java +++ b/webservices/compbio/stat/collector/InputFilter.java @@ -14,6 +14,7 @@ import compbio.ws.client.WSTester; public class InputFilter { private static final Logger log = Logger.getLogger(InputFilter.class); + /** * Accepts input as valid unless it is a test input * @@ -28,12 +29,17 @@ public class InputFilter { assert fastainput.length == 4; String[] aligninput = WSTester.fastaAlignment.split("\n"); assert aligninput.length == 4; + String[] rnaaligninput = WSTester.clustalRNAAlignment.split("\n"); + assert aligninput.length == 5; // We do now know the type of the input here so must compare with both // references boolean isReference = compareLines(input, fastainput); if (!isReference) { isReference = compareLines(input, aligninput); } + if (!isReference) { + isReference = compareClustalLines(input, rnaaligninput); + } // only accept genuine input return !isReference; } @@ -45,7 +51,7 @@ public class InputFilter { reader = new BufferedReader(new FileReader(input)); // only compare first four lines of the file with reference // because the reference length is only 4 lines - for (int i = 0; i < 4; i++) { + for (int i = 0; i < reference.length; i++) { String line = reader.readLine(); if (Util.isEmpty(line)) { status = false; @@ -65,4 +71,32 @@ public class InputFilter { } return status; } + + private static boolean compareClustalLines(File input, String[] reference) { + BufferedReader reader = null; + boolean status = true; + try { + reader = new BufferedReader(new FileReader(input)); + // only compare first four lines of the file with reference + // because the reference length is only 4 lines + int i = 0; + String line; + while (null != (line = reader.readLine())) { + if (!Util.isEmpty(line)) { + line = line.trim(); + if (!line.equals(reference[i].trim())) { + status = false; + break; + } + ++i; + } + } + reader.close(); + } catch (IOException ioe) { + log.warn(ioe, ioe.getCause()); + } finally { + FileUtil.closeSilently(reader); + } + return status; + } } diff --git a/webservices/compbio/ws/client/WSTester.java b/webservices/compbio/ws/client/WSTester.java index 928288c..5450a1d 100644 --- a/webservices/compbio/ws/client/WSTester.java +++ b/webservices/compbio/ws/client/WSTester.java @@ -80,6 +80,12 @@ public class WSTester { ">Foo\nC-UUGCGUUAAUGAGAACAGAAACG-UAAA--CUAUAA-CCUAG-G-GGUUUCUGUUGGAUGGUUG----GCAAC\n" + ">Bar\nG-UGGCGCUUAUGACGCAGUUGUCU-UAAA-CUCGAAC--UCGA-GCGGGCAAUUGCUGAU-UACGAUUAACCAC\n"; + public static final String clustalRNAAlignment = + "CLUSTAL\n" + + "Foo C-UUGCGUUAAUGAGAACAGAAACG-UAAA--CUAUAA-CCUAG-G-GGUUUCUGUUGGA\n" + + "Bar G-UGGCGCUUAUGACGCAGUUGUCU-UAAA-CUCGAAC--UCGA-GCGGGCAAUUGCUGA\n" + + "Foo UGGUUG----GCAAC\n" + + "Bar U-UACGAUUAACCAC"; /** * Status strings */ -- 1.7.10.2