Skip to content

Commit 80cc9de

Browse files
committed
output in column fashion
1 parent 5c4e341 commit 80cc9de

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/metric.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ def run(args):
281281
if args.extend_1:
282282
metric_header += "\tss_string"
283283
fout.write("{}\n".format(metric_header))
284+
285+
if args.output_current_column:
286+
column_raw_samples = {}
287+
284288
if use_paf == 1 and plot_sig_ref_flag == 0:
285289
print("Info: Signal to read method using PAF ...")
286290
with open(args.alignment, "r") as handle:
@@ -630,6 +634,15 @@ def run(args):
630634
if i < len(ref_pos_dic) - 1:
631635
print("\t", end="")
632636
print()
637+
if args.output_current_column:
638+
for i in range(0, len(ref_pos_dic)):
639+
sublist = ref_pos_dic[i]
640+
if not any(np.isnan(x) for x in sublist) and len(sublist) > 0:
641+
rounded_sublist = [round(x, 2) for x in sublist]
642+
if i in column_raw_samples:
643+
column_raw_samples[i] += rounded_sublist
644+
else:
645+
column_raw_samples[i] = rounded_sublist
633646
elif use_paf == 1 and plot_sig_ref_flag == 1:
634647
print("Info: Signal to reference method using PAF ...")
635648
fasta_reads = Fasta(args.file)
@@ -836,6 +849,14 @@ def run(args):
836849
else:
837850
raise Exception("Error: You should not have ended up here. Please check your arguments")
838851

852+
if args.output_current_column:
853+
for key, item in column_raw_samples.items():
854+
array = np.array(item)
855+
mean = np.mean(array)
856+
darray = array/mean
857+
print(', '.join(map(str, darray)))
858+
# print(', '.join(map(str, item)))
859+
839860
print("Number of records: {}".format(num_plots))
840861
if num_plots == 0:
841862
print("Squigualiser only plots reads that span across the specified region entirely. Reduce the region interval and double check with IGV : {}".format(num_plots))
@@ -872,6 +893,7 @@ def argparser():
872893
parser.add_argument('--extend_0', required=False, action='store_true', help="print matches, deletions, insertions arrays")
873894
parser.add_argument('--extend_1', required=False, action='store_true', help="print ss string for the given region")
874895
parser.add_argument('--output_current', required=False, action='store_true', help="print signal values")
896+
parser.add_argument('--output_current_column', required=False, action='store_true', help="print signal values per column")
875897
return parser
876898

877899
if __name__ == "__main__":

0 commit comments

Comments
 (0)