Mercurial > repos > iuc > tbl2gff3
changeset 1:4a7f4b0cc0a3 draft default tip
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/tbl2gff3 commit db75a8489a1f61ea30abe9b91f6febac8b34204f"
author | iuc |
---|---|
date | Thu, 03 Dec 2020 16:59:23 +0000 |
parents | 965674d88d34 |
children | |
files | tbl2gff3.py tbl2gff3.xml test-data/infer.gff3 test-data/infer.tab |
diffstat | 4 files changed, 54 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- 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')
--- 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 @@ -<tool id="tbl2gff3" name="Table to GFF3" version="1.1"> +<tool id="tbl2gff3" name="Table to GFF3" version="1.2"> <description></description> <macros> <import>macros.xml</import> @@ -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 @@ <param label="Table" name="table" type="data" format="tabular"/> <param name="rid" type="text" value="1" label="Record ID column or value" optional="false" help="@HELP@"/> - <param name="begin" type="text" value="" optional="false" label="Feature start column or value" help="@HELP@"/> - <param name="end" type="text" value="" optional="false" label="Feature end column or value" help="@HELP@"/> - <param name="type" type="text" value="sequence_feature" label="Feature type column or value" help="@HELP@"/> - <param name="score" type="text" value="" label="Feature score column or value" help="@HELP@"/> - <param name="source" type="text" value="tbl2gff3" label="Feature source column or value" help="@HELP@"/> + <param name="begin" type="text" value="" optional="false" label="Start column or value" help="@HELP@"/> + <param name="end" type="text" value="" optional="false" label="End column or value" help="@HELP@"/> + <param name="type" type="text" value="sequence_feature" label="Type column or value" help="@HELP@"/> + <param name="score" type="text" value="" label="Score column or value" help="@HELP@"/> + <param name="source" type="text" value="tbl2gff3" label="Source column or value" help="@HELP@"/> <conditional name="strand"> <param name="strand_select" type="select" label="Strand"> + <option value="infer">Infer</option> <option value="none">Not specified</option> <option value="column">From Column</option> <option value="value">Specify Value</option> </param> <when value="none" /> + <when value="infer" /> <when value="column" > <param name="strand" type="text" value="" label="Strand column" /> </when> @@ -104,6 +108,17 @@ <output name="output" file="blast.gff3" /> </test> + <test> + <param name="table" ftype="tabular" value="infer.tab" /> + <param name="rid" value="1" /> + <param name="begin" value="2" /> + <param name="end" value="3" /> + <conditional name="strand"> + <param name="strand_select" value="infer"/> + </conditional> + <output name="output" file="infer.gff3" /> + + </test> </tests> <help><![CDATA[ **What it does**