From f74f336b6d80eb3472a911b9da63bdd6f2d81a3e Mon Sep 17 00:00:00 2001 From: meiermark Date: Wed, 12 Jul 2017 17:15:42 +0200 Subject: [PATCH] bugfix: a3m.py check functions did not return True... never... --- lib/ffindex | 2 +- scripts/a3m.py | 17 ++++++++++++++--- scripts/check_a3m.py | 9 ++++----- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/ffindex b/lib/ffindex index cceb0ffb..360e4176 160000 --- a/lib/ffindex +++ b/lib/ffindex @@ -1 +1 @@ -Subproject commit cceb0ffb8fe532dfee04385b5b24bebf7dc68ece +Subproject commit 360e4176ece531be34a94298c808349916d016ac diff --git a/scripts/a3m.py b/scripts/a3m.py index 9767869d..f6f65779 100644 --- a/scripts/a3m.py +++ b/scripts/a3m.py @@ -70,9 +70,12 @@ def check_and_add_annotation(self, header, sequence): return False def check_match_states(self, match_states): + if not self.nr_match_states: + self.nr_match_states = match_states + if match_states == 0: raise A3MFormatError("Sequence with zero match states!") - elif self.nr_match_states and match_states != self.nr_match_states: + elif match_states != self.nr_match_states: raise A3MFormatError( ("Sequence with diverging number " "of match states ({} vs. {})!").format( @@ -80,8 +83,7 @@ def check_match_states(self, match_states): self.nr_match_states ) ) - else: - self.nr_match_states = match_states + def check_ss_conf(self, sequence): count_match_states = sum((c in self.VALID_SS_CONF_STATES @@ -96,6 +98,8 @@ def check_ss_conf(self, sequence): raise A3MFormatError( ("Undefined character(s) '{}' in predicted " "secondary structure confidence!").format(invalid_states)) + else: + return True def check_ss_pred(self, sequence): count_match_states = sum((c in self.VALID_SS_STATES @@ -110,6 +114,8 @@ def check_ss_pred(self, sequence): raise A3MFormatError( ("Undefined character(s) '{}' in predicted " "secondary structure!").format(invalid_states)) + else: + return True def check_dssp(self, sequence): count_match_states = sum( @@ -122,6 +128,8 @@ def check_dssp(self, sequence): raise A3MFormatError( ("Undefined character(s) '{}' in " "dssp annotation!").format(invalid_states)) + else: + return True def check_sequence(self, sequence): count_match_states = sum((c in self.VALID_MATCH_STATES @@ -129,6 +137,7 @@ def check_sequence(self, sequence): for c in sequence) self.check_match_states(count_match_states) + invalid_states = set(sequence) - self.VALID_MATCH_STATES invalid_states -= self.VALID_GAP_STATES invalid_states -= self.VALID_INSERTION_STATES @@ -137,6 +146,8 @@ def check_sequence(self, sequence): raise A3MFormatError( ("Undefined character(s) '{}' in " "protein sequence!").format(invalid_states)) + else: + return True def get_sub_sequence(self, sequence, limits): sub_sequence = [] diff --git a/scripts/check_a3m.py b/scripts/check_a3m.py index 449420c6..8578312f 100755 --- a/scripts/check_a3m.py +++ b/scripts/check_a3m.py @@ -7,18 +7,18 @@ def check_a3m(filename): a3m = A3M_Container() - + if(filename.lower() == "stdin"): fh = sys.stdin else: fh = open(filename, "r") - + try: a3m.read_a3m(fh) except A3MFormatError as e: - sys.stderr.write(e) + sys.stderr.write(str(e)) exit(1) - + def main(): filename = sys.argv[1] @@ -27,4 +27,3 @@ def main(): if __name__ == "__main__": main() -