Skip to content

Commit

Permalink
debugging a bug I added doing the pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
KatyBrown committed May 14, 2024
1 parent d294923 commit 8667a73
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 28 deletions.
37 changes: 24 additions & 13 deletions CIAlign/consensusSeq.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,11 +660,21 @@ def calcConservationAli(alignment, typ):
Calculate alignment conservation as the heights the letters would
be in a sequence logo.
Parameters
-----------
alignment: np.array
The alignment stored as a numpy array
typ: str
nt or aa
Returns
-------
heights: list
A list containing the letter height for each column
ents: list
A list containing the entropy calculated for each column
'''
alignment_width = len(alignment[0, :])
seq_count = len(alignment[:, 0])
Expand Down Expand Up @@ -697,25 +707,26 @@ def compareAlignmentConsensus(arr):
A numpy array stored as new_arr, which is a boolean array
comparing the arr to its consensus.
'''
consensus, _ = np.array(findConsensus(arr, ''))
consensus, _ = np.array(findConsensus(arr, '',
consensus_type='majority_nongap'))
bool_array = np.array([])
bool_arrL = np.empty(dtype=bool, shape=(0, len(consensus)))
# declares the numpy arrays
for e in range(1, (len(arr[:, 0])+1)):
# iterates over the rows of the sequences
z = e - 1
for i in range(1, (len(arr[0, :])+1)):
# iterates over the columns of the sequences
x = i - 1
if arr[z, x] == consensus[x]:
# verifies if the current value being iterated is equal to
# the equivalent value inline with the consensus
bool_array = np.append(bool_array, [True], axis=None)
else:
bool_array = np.append(bool_array, [False], axis=None)
bool_arrL = np.vstack([bool_arrL,
bool_array])
bool_array = np.array([])
for i in range(1, (len(arr[0, :])+1)):
# iterates over the columns of the sequences
x = i - 1
if arr[z, x] == consensus[x]:
# verifies if the current value being iterated is equal to
# the equivalent value inline with the consensus
bool_array = np.append(bool_array, [True], axis=None)
else:
bool_array = np.append(bool_array, [False], axis=None)
bool_arrL = np.vstack([bool_arrL,
bool_array])
bool_array = np.array([])
new_arr = copy.deepcopy(bool_arrL)
new_arr = bool_arrL.astype(bool)
# returns the new boolean array containing the verified alignment
Expand Down
32 changes: 17 additions & 15 deletions CIAlign/runCIAlign.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,11 @@ def runMiniAlignments(args, log, orig_arr, orig_nams, arr, nams,
print("Plotting mini alignment for input")
outf = "%s_input.%s" % (args.outfile_stem, args.plot_format)
miniAlignments.drawMiniAlignment(orig_arr, orig_nams, log,
outf, typ, args.plot_dpi,
False, args.plot_width,
args.plot_height,
outf, typ,
dpi=args.plot_dpi,
title=False,
width=args.plot_width,
height=args.plot_height,
force_numbers=fn,
palette=args.palette)
# Mini alignment of CIAlign output
Expand All @@ -850,19 +852,19 @@ def runMiniAlignments(args, log, orig_arr, orig_nams, arr, nams,
if not args.plot_keep_numbers:
miniAlignments.drawMiniAlignment(arr, nams, log,
outf, typ,
args.plot_dpi,
False,
args.plot_width,
args.plot_height,
dpi=args.plot_dpi,
title=False,
width=args.plot_width,
height=args.plot_height,
force_numbers=fn,
palette=args.palette)
else:
miniAlignments.drawMiniAlignment(arr, nams, log,
outf, typ,
args.plot_dpi,
False,
args.plot_width,
args.plot_height,
dpi=args.plot_dpi,
title=False,
width=args.plot_width,
height=args.plot_height,
orig_nams=orig_nams,
keep_numbers=True,
force_numbers=fn,
Expand All @@ -876,10 +878,10 @@ def runMiniAlignments(args, log, orig_arr, orig_nams, arr, nams,
outf = "%s_markup.%s" % (args.outfile_stem, args.plot_format)
miniAlignments.drawMiniAlignment(orig_arr, orig_nams, log,
outf, typ,
args.plot_dpi,
False,
args.plot_width,
args.plot_height,
dpi=args.plot_dpi,
title=False,
width=args.plot_width,
height=args.plot_height,
markup=True,
markupdict=markupdict,
force_numbers=fn,
Expand Down

0 comments on commit 8667a73

Please sign in to comment.