Mercurial > repos > petrn > repeatexplorer
comparison bin/last_wrapper.py @ 0:f6ebec6e235e draft
Uploaded
| author | petrn |
|---|---|
| date | Thu, 19 Dec 2019 13:46:43 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f6ebec6e235e |
|---|---|
| 1 #!/usr/bin/env python3 | |
| 2 ''' | |
| 3 wrapper for last program | |
| 4 run last with BlastTab+ output and return mgblast like formated output | |
| 5 last BlastTab+ output column order: | |
| 6 1 query name | |
| 7 2 reference name | |
| 8 3 percent identity | |
| 9 4 alignment length | |
| 10 5 mismatches | |
| 11 6 gap opens | |
| 12 7 query start | |
| 13 8 query end | |
| 14 9 reference start | |
| 15 10 reference end | |
| 16 11 e-value | |
| 17 12 bitscore | |
| 18 13 length of query | |
| 19 14 length of reference sequence | |
| 20 (accordin lastal manual - more column may be added in future) | |
| 21 | |
| 22 Needed mgblast order: | |
| 23 | |
| 24 qseqid 1 -> 1 | |
| 25 qlen 2 -> 13 | |
| 26 qstart 3 -> 7 | |
| 27 qend 4 -> 8 | |
| 28 sseqid 5 -> 2 | |
| 29 slen 6 -> 14 | |
| 30 sstart 7 -> 9 | |
| 31 send 8 -> 10 | |
| 32 pident 9 -> 3 | |
| 33 bitscore 10-> 12 | |
| 34 evalue 11-> 11 | |
| 35 sstrand 12-> must be evaluated! | |
| 36 | |
| 37 ''' | |
| 38 import subprocess | |
| 39 import sys | |
| 40 last_command = " ".join(["lastal"] + sys.argv[1:]) | |
| 41 p = subprocess.Popen(last_command, shell=True, stdout=subprocess.PIPE) | |
| 42 for j in p.stdout: | |
| 43 line = j.decode() | |
| 44 if line[0] != "#": | |
| 45 items = line.split("\t") | |
| 46 strand = "+" if int(items[6]) < int(items[7]) else "-" | |
| 47 out = "\t".join([items[i - 1] | |
| 48 for i in [1, 13, 7, 8, 2, 14, 9, 10, 3, 12, 11] | |
| 49 ]) + "\t" + strand + "\n" | |
| 50 print(out, end="") |
