diff --git a/bin/transvar b/bin/transvar index 8b6734d..fdcbe1d 100755 --- a/bin/transvar +++ b/bin/transvar @@ -16,7 +16,7 @@ from transvar.localdb import add_parser_index if __name__ == '__main__': import sys - if sys.argv[1] in ['-version', '--version']: + if len([a for a in sys.argv if a in ['-version', '--version']]) > 0: import transvar sys.stderr.write("TransVar Version %s\n" % transvar.__version__) sys.exit(1) diff --git a/test/test.py b/test/test.py index 408f15f..da46c0e 100755 --- a/test/test.py +++ b/test/test.py @@ -43,47 +43,93 @@ def wrap(line): yield ' '*3+line[:k] line = line[k:] -fh = open(sys.argv[2], 'w') # open('README.md.temp', 'w') +indir = sys.argv[1] +outdir = sys.argv[2] + +if not os.path.exists(outdir): + os.mkdir(outdir) +# outdir = open(sys.argv[2], 'w') # open('README.md.temp', 'w') import transvar -result = '' -for line in open(sys.argv[1]): +for ifn in os.listdir(indir): + if not ifn.endswith(".md"): + continue - line = line.replace('@VERSION', transvar.__version__) + ifh = open(os.path.join(indir, ifn)) - if line.startswith('$'): # exexcute sentinel + ofn = os.path.join(outdir, ifn) + ofh = open(ofn, "w") - fh.write(line) - line = line[2:].strip() - ar = re.split(r'[\'"]', line.strip()) + result = '' + tofill = False + infill = False + for line in ifh: - B = [] - for i, e in enumerate(ar): - if i % 2 == 0: - if len(e.strip())>0: - B.extend(e.strip().split()) - else: - B.append(e.strip()) + line = line.replace('@VERSION', transvar.__version__) + + if line.startswith('$'): # exexcute sentinel + + ofh.write(line) + line = line[2:].strip() + ar = re.split(r'[\'"]', line.strip()) + + B = [] + for i, e in enumerate(ar): + if i % 2 == 0: + if len(e.strip())>0: + B.extend(e.strip().split()) + else: + B.append(e.strip()) + + p = Popen(B, stdin=PIPE, stdout=PIPE, stderr=PIPE) + result, err = p.communicate() + result = result.strip() - p = Popen(B, stdin=PIPE, stdout=PIPE, stderr=PIPE) - result, err = p.communicate() - result = result.strip() + print + print '======'+line+'======' + print result + print '\n'.join([rr for rr in result.split('\n') if not (len(rr.strip()) == 0 or rr.startswith('[') or rr.startswith('input'))]) + tofill = True + infill = False + oldfill = '' - print - print '======'+line+'======' - print '\n'.join([rr for rr in result.split('\n') if not (len(rr.strip()) == 0 or rr.startswith('[') or rr.startswith('input'))]) + elif line.startswith('```text') and tofill: + infill = True + tofill = False + ofh.write(line) + + elif line.startswith('```') and infill: + + newfill = '' + for rr in result.split('\n'): + + if len(rr.strip()) == 0 or rr.startswith('[') or rr.startswith('input'): + continue + + for r in wrap(rr): + newfill += r+'\n' + + if newfill != oldfill: + print '\n+++ NEW +++' + print newfill + print '\n+++ OLD +++' + print oldfill + raw_input("Difference ...") + else: + print "\nSame!\n" - elif line.startswith('@'): + ofh.write(newfill) + ofh.write('```\n') - for rr in result.split('\n'): + infill = False - if len(rr.strip()) == 0 or rr.startswith('[') or rr.startswith('input'): - continue + elif infill: + oldfill += line - for r in wrap(rr): - fh.write(r+'\n') + else: - else: + ofh.write(line) - fh.write(line) + ifh.close() + ofh.close() diff --git a/transvar/mutation.py b/transvar/mutation.py index f65381e..565d6c3 100755 --- a/transvar/mutation.py +++ b/transvar/mutation.py @@ -395,7 +395,9 @@ def vcf_parse_mutation(args, at='g'): q.refseq = ref.upper() q.altseq = alt.upper() else: - err_raise(InvalidInputError, 'invalid VCF line: %s' % line) + q = Query() + q.msg = "InvalidVCFLine%s" % line + err_warn("Invalid VCF Line: %s" % line) q.op = line.strip() diff --git a/transvar/record.py b/transvar/record.py index a71c048..a7f2f38 100755 --- a/transvar/record.py +++ b/transvar/record.py @@ -282,6 +282,8 @@ def __init__(self): self.is_codon = True self.gn_name = None self.tpt = '' + self.msg = '' + self.tok = None # by default, is a failed query def set_pos(self, pos_str):