Mercurial > repos > iuc > transit_resampling
diff gff_to_prot.py @ 5:3fcb70c1ca78 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/transit/ commit 73c6b2baf9dda26c6809a4f36582f7cbdb161ea1
| author | iuc |
|---|---|
| date | Mon, 22 Apr 2019 14:40:33 -0400 |
| parents | 173bf0f6ca1e |
| children |
line wrap: on
line diff
--- a/gff_to_prot.py Wed Apr 03 14:43:41 2019 -0400 +++ b/gff_to_prot.py Mon Apr 22 14:40:33 2019 -0400 @@ -1,7 +1,8 @@ #!/usr/bin/env python +import csv +import os import sys -import os -import csv + def get_description(line, parent): cols = line.split('\t') @@ -22,30 +23,34 @@ lines = gff_file.readlines() gff_file.close() for i, line in enumerate(lines): - lie = line.strip() - if line.startswith('#'): continue + line = line.strip() + if line.startswith('#'): + continue cols = line.split('\t') if (len(cols) < 9): print("Ignoring invalid row with entries: {0}".format(cols)) - elif (cols[2]) == "region": continue - elif (cols[2]) == "CDS": continue + elif (cols[2]) == "region": + continue + elif (cols[2]) == "CDS": + continue elif (cols[2]) == "gene": start = int(cols[3]) end = int(cols[4]) strand = cols[6].strip() labels = {} - diff = int(abs(end - start)/3) ## What is this called? + diff = int(abs(end - start) / 3) # What is this called? for pair in cols[8].split(";"): k, v = pair.split('=') labels[k.strip()] = v.strip() - Rv = labels["locus_tag"].strip() # error out if not found + Rv = labels["locus_tag"].strip() # error out if not found gene = labels.get('Name', '') desc = get_description(lines[i + 1], labels.get("ID", "")) if (i + 1) < len(lines) else '-' vals = [desc, start, end, strand, diff, '-', '-', gene, Rv, '-'] writer.writerow(vals) output_file.close() + if __name__ == "__main__": usage_string = "Usage: python gff-prot-converter.py <gff filename> <output filename>"
