Skip to content

Commit

Permalink
codestyle
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanssen2 committed May 14, 2024
1 parent a949a8c commit a131c53
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 32 deletions.
28 changes: 14 additions & 14 deletions sepp/alignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
try:
from collections.abc import Mapping # noqa
except ImportError:
from collections import Mapping
from collections import Mapping

import copy
from sepp import get_logger
import io
Expand Down Expand Up @@ -771,8 +771,8 @@ def merge_in(self, other, convert_to_string=True):
if me != me_len and self.is_insertion_column(me):
''' We both have a series of insertion columns'''
start = me
while(me != me_len and self.is_insertion_column(me) and
she != she_len and other.is_insertion_column(she)):
while (me != me_len and self.is_insertion_column(me) and
she != she_len and other.is_insertion_column(she)):
me += 1
she += 1
merged_insertion_columns += 1
Expand Down Expand Up @@ -805,24 +805,24 @@ def merge_in(self, other, convert_to_string=True):
self.col_labels[start:me] = list(
range(insertion, insertion-run, -1))
insertion -= run
elif(she == she_len or (me != me_len and
self.col_labels[me] < other.col_labels[she])):
elif (she == she_len or (me != me_len and
self.col_labels[me] < other.col_labels[she])):
''' My column is not present (i.e. was allgap) in the
"other"'''
start = me
while(me < me_len and (she == she_len or me != me_len and
self.col_labels[me] < other.col_labels[she])):
while (me < me_len and (she == she_len or me != me_len and
self.col_labels[me] < other.col_labels[she])):
me += 1
run = me - start
ins = bytearray(b"-") * run
for v in selfother.values():
v[start:start] = ins
elif(me == me_len or (she != she_len and
self.col_labels[me] > other.col_labels[she])):
elif (me == me_len or (she != she_len and
self.col_labels[me] > other.col_labels[she])):
''' Her column is not present (i.e. was allgap) in "me"'''
start = she
while(she < she_len and (me == me_len or she != she_len and
self.col_labels[me] > other.col_labels[she])):
while (she < she_len and (me == me_len or she != she_len and
self.col_labels[me] > other.col_labels[she])):
she += 1
run = she - start
ins = bytearray(b"-") * run
Expand All @@ -833,8 +833,8 @@ def merge_in(self, other, convert_to_string=True):
me_len += run
elif self.col_labels[me] == other.col_labels[she]:
''' A shared column'''
while(me < me_len and she < she_len and
self.col_labels[me] == other.col_labels[she]):
while (me < me_len and she < she_len and
self.col_labels[me] == other.col_labels[she]):
she += 1
me += 1
else:
Expand Down
8 changes: 4 additions & 4 deletions sepp/exhaustive.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from sepp.algorithm import AbstractAlgorithm
from sepp.config import options
from sepp.tree import PhylogeneticTree
from sepp.alignment import MutableAlignment, ExtendedAlignment,\
hamming_distance
from sepp.alignment import (MutableAlignment, ExtendedAlignment,
hamming_distance)
from sepp.problem import SeppProblem, RootProblem
from dendropy.datamodel.treemodel import Tree
from sepp.jobs import HMMBuildJob, HMMSearchJob, HMMAlignJob, PplacerJob,\
MergeJsonJob
from sepp.jobs import (HMMBuildJob, HMMSearchJob, HMMAlignJob, PplacerJob,
MergeJsonJob)
from sepp.scheduler import JobPool, Join
from sepp import get_logger
from sepp.math_utils import lcm
Expand Down
6 changes: 3 additions & 3 deletions sepp/exhaustive_upp.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def generate_backbone(self):
fragments = MutableAlignment()
if options().median_full_length is not None \
or options().full_length_range is not None:
if options().median_full_length == -1 \
if options().median_full_length == -1 \
or 0 < options().median_full_length < 1:
# for backward compatibility, -1 is mapped to 0.5 quantile.
if options().median_full_length == -1:
Expand Down Expand Up @@ -415,8 +415,8 @@ def augment_parser():
help="Consider all fragments that are 25%% longer or shorter than N "
"to be excluded from the backbone. If value is -1, then UPP will"
" use the median of the sequences as the median full length. "
"Use 0 < N < 1 for UPP to use quartiles. e.g. 0.25 for the first "
" quartile and 0.75 for the third quartile. "
"Use 0 < N < 1 for UPP to use quartiles. e.g. 0.25 for the "
"first quartile and 0.75 for the third quartile. "
"[default: None]")
decompGroup.add_argument(
"-T", "--backbone_threshold", type=float,
Expand Down
2 changes: 1 addition & 1 deletion sepp/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,5 +447,5 @@ def is_valid_tree(t):
if num_children == 2:
# What is with this code? Why do we check the same variable twice?
# Bug? NN
assert((not rc[0].child_nodes()) and (not rc[0].child_nodes()))
assert ((not rc[0].child_nodes()) and (not rc[0].child_nodes()))
return True
4 changes: 2 additions & 2 deletions test/unittest/TestFork.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def run():

# Test one of the jobs, to see if it is successful
if sample_job.ready() and sample_job.successful():
assert(jobs[3].result_set is True)
assert (jobs[3].result_set is True)
else:
assert(jobs[3].result_set is False)
assert (jobs[3].result_set is False)

errors = pool.get_all_job_errors()
# print("Following job errors were raised:", errors)
Expand Down
4 changes: 2 additions & 2 deletions test/unittest/testAlignment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
@author: smirarab
'''
import unittest
from sepp.alignment import MutableAlignment, ReadonlySubalignment,\
ExtendedAlignment
from sepp.alignment import (MutableAlignment, ReadonlySubalignment,
ExtendedAlignment)
from sepp.problem import SeppProblem
from sepp.filemgr import get_data_path
from tempfile import mkstemp
Expand Down
4 changes: 2 additions & 2 deletions test/unittest/testConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ def testLog(self):
sepp._DEBUG = True
sepp.reset_loggers()
sepp.jobs._LOG.debug("test debugging works")
assert(sepp.jobs._LOG.getEffectiveLevel() == logging.DEBUG)
assert (sepp.jobs._LOG.getEffectiveLevel() == logging.DEBUG)

sepp._DEBUG = False
sepp.reset_loggers()
sepp.jobs._LOG.debug("test debugging is disabled")
assert(sepp.jobs._LOG.getEffectiveLevel() == logging.INFO)
assert (sepp.jobs._LOG.getEffectiveLevel() == logging.INFO)

sepp._DEBUG = sdb
sepp.reset_loggers()
Expand Down
7 changes: 3 additions & 4 deletions test/unittest/testUPP.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@ def tearDown(self):
shutil.rmtree(self.x.options.outdir, ignore_errors=True)

def test_id_collision_working(self):

self.x.run()
self.assertTrue(self.x.results is not None)
assert(len(self.x.results) == 490)
assert(300 < len(self.x.results['SEQ396']) < 600)
assert(len(self.x.results['SEQ554'].replace('-', '')) == 57)
assert (len(self.x.results) == 490)
assert (300 < len(self.x.results['SEQ396']) < 600)
assert (len(self.x.results['SEQ554'].replace('-', '')) == 57)


if __name__ == "__main__":
Expand Down

0 comments on commit a131c53

Please sign in to comment.