# HG changeset patch # User iuc # Date 1607014763 0 # Node ID 4a7f4b0cc0a3691319996e8c8822e0f3e7915e25 # Parent 965674d88d34f0265cc23697a8ef6fcac8388f70 "planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/tbl2gff3 commit db75a8489a1f61ea30abe9b91f6febac8b34204f" diff -r 965674d88d34 -r 4a7f4b0cc0a3 tbl2gff3.py --- a/tbl2gff3.py Tue Jul 07 04:20:40 2020 -0400 +++ b/tbl2gff3.py Thu Dec 03 16:59:23 2020 +0000 @@ -1,5 +1,6 @@ #!/usr/bin/env python import argparse +import collections import csv import sys @@ -32,9 +33,10 @@ a=None, strand_column=None, strand_value=None, + strand_infer=False, ): - records = {} + records = collections.OrderedDict() for row in csv.reader(table, delimiter="\t"): # print(', '.join(row)) @@ -51,22 +53,34 @@ q["source"] = c(row, source, "tbl2gff3") + begin_i = int(c(row, begin)) + end_i = int(c(row, end)) + + begin_f = min(begin_i, end_i) + end_f = max(begin_i, end_i) + _str = None if strand_column is not None: _str = int(c(row, strand_column)) elif strand_value is not None: _str = int(strand_value) + if strand_infer: + if begin_i > begin_f: + _str = -1 + else: + _str = 1 - for x in a: - k, v = x.split(":", 1) - _v = c(row, v) - if k in q: - q[k].append(_v) - else: - q[k] = [_v] + if a is not None: + for x in a: + k, v = x.split(":", 1) + _v = c(row, v) + if k in q: + q[k].append(_v) + else: + q[k] = [_v] f = SeqFeature( - FeatureLocation(int(c(row, begin)), int(c(row, end))), + FeatureLocation(begin_f, end_f), type=c(row, type), strand=_str, qualifiers=q, @@ -85,6 +99,7 @@ parser.add_argument("--type", help="feature type column") parser.add_argument("--score", help="score column") parser.add_argument("--source", help="source column") + parser.add_argument("--strand_infer", action='store_true', help="infer strand") parser.add_argument("--strand_column", help="strand column") parser.add_argument("--strand_value", help="strand value") # parser.add_argument('--frame', help='frame column') diff -r 965674d88d34 -r 4a7f4b0cc0a3 tbl2gff3.xml --- a/tbl2gff3.xml Tue Jul 07 04:20:40 2020 -0400 +++ b/tbl2gff3.xml Thu Dec 03 16:59:23 2020 +0000 @@ -1,4 +1,4 @@ - + macros.xml @@ -24,7 +24,9 @@ --source '$source' #end if - #if str($strand.strand_select) != "none": + #if str($strand.strand_select) == 'infer': + --strand_infer + #else if str($strand.strand_select) != "none": --strand_${strand.strand_select} '${strand.strand}' #end if @@ -38,20 +40,22 @@ - - - - - + + + + + + + @@ -104,6 +108,17 @@ + + + + + + + + + + +