Commit 6b486e49 authored by MARIJON Pierre's avatar MARIJON Pierre

Add progression option when paf are read

parent ca999082
......@@ -2,7 +2,9 @@
# -*- coding: utf-8 -*-
import re
import os
import sys
import time
import logging
......@@ -200,7 +202,7 @@ class Parser:
def _add_internal(self, name_a, strand_a, name_b, strand_b, ov_len,
nb_match, overhang_maplen):
self._add_link(self, name_a, strand_a, name_b, strand_b, ov_len,
self._add_link(name_a, strand_a, name_b, strand_b, ov_len,
nb_match, overhang_maplen)
def _add_containment(self, container, strand_ner, contained, strand_ned, pos, length):
......@@ -274,6 +276,8 @@ def main(args):
help="Remove all containment")
parser.add_argument("-i", "--remove-all-internal", action='store_true',
help="Remove all internal match")
parser.add_argument("-p", "--progression", action='store_true',
help="Show a progress bar durring reading")
arg = vars(parser.parse_args(args))
......@@ -284,9 +288,24 @@ def main(args):
parser = Parser(not rm_all_contain, not rm_all_internal)
file_size = os.path.getsize(paf)
last_time = time.time()
print("begin parsing")
for line in arg["paf"]:
while "read all line in file":
line = arg["paf"].readline()
if not line:
if arg["progression"] and time.time() - last_time > 2:
precent = format((arg["paf"].tell() * 100) / file_size, '.2f')
precent += "%"
sys.stdout.write("\b" * len(precent))
last_time = time.time()
print("end parsing")
print("begin cleaning")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment