annotate gff3_rebase.py @ 3:e5463684db98 draft default tip

"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 38c7fd1eea12a147f4d7997dc982984187aae01a"
author iuc
date Mon, 11 Oct 2021 10:08:15 +0000
parents 8ad4b86dbce1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
1 #!/usr/bin/env python
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
2 import argparse
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
3 import copy
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
4 import logging
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
5 import sys
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
6
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
7 from BCBio import GFF
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
8 from Bio.SeqFeature import FeatureLocation
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
9
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
10 logging.basicConfig(level=logging.INFO)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
11 log = logging.getLogger(__name__)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
12
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
13 __author__ = "Eric Rasche"
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
14 __version__ = "0.4.0"
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
15 __maintainer__ = "Eric Rasche"
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
16 __email__ = "esr@tamu.edu"
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
17
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
18
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
19 def feature_lambda(feature_list, test, test_kwargs, subfeatures=True):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
20 """Recursively search through features, testing each with a test function, yielding matches.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
21
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
22 GFF3 is a hierachical data structure, so we need to be able to recursively
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
23 search through features. E.g. if you're looking for a feature with
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
24 ID='bob.42', you can't just do a simple list comprehension with a test
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
25 case. You don't know how deeply burried bob.42 will be in the feature tree. This is where feature_lambda steps in.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
26
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
27 :type feature_list: list
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
28 :param feature_list: an iterable of features
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
29
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
30 :type test: function reference
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
31 :param test: a closure with the method signature (feature, **kwargs) where
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
32 the kwargs are those passed in the next argument. This
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
33 function should return True or False, True if the feature is
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
34 to be yielded as part of the main feature_lambda function, or
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
35 False if it is to be ignored. This function CAN mutate the
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
36 features passed to it (think "apply").
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
37
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
38 :type test_kwargs: dictionary
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
39 :param test_kwargs: kwargs to pass to your closure when it is called.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
40
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
41 :type subfeatures: boolean
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
42 :param subfeatures: when a feature is matched, should just that feature be
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
43 yielded to the caller, or should the entire sub_feature
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
44 tree for that feature be included? subfeatures=True is
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
45 useful in cases such as searching for a gene feature,
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
46 and wanting to know what RBS/Shine_Dalgarno_sequences
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
47 are in the sub_feature tree (which can be accomplished
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
48 with two feature_lambda calls). subfeatures=False is
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
49 useful in cases when you want to process (and possibly
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
50 return) the entire feature tree, such as applying a
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
51 qualifier to every single feature.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
52
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
53 :rtype: yielded list
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
54 :return: Yields a list of matching features.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
55 """
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
56 # Either the top level set of [features] or the subfeature attribute
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
57 for feature in feature_list:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
58 if test(feature, **test_kwargs):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
59 if not subfeatures:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
60 feature_copy = copy.deepcopy(feature)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
61 feature_copy.sub_features = []
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
62 yield feature_copy
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
63 else:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
64 yield feature
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
65
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
66 if hasattr(feature, 'sub_features'):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
67 for x in feature_lambda(feature.sub_features, test, test_kwargs, subfeatures=subfeatures):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
68 yield x
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
69
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
70
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
71 def feature_test_qual_value(feature, **kwargs):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
72 """Test qualifier values.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
73
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
74 For every feature, check that at least one value in
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
75 feature.quailfiers(kwargs['qualifier']) is in kwargs['attribute_list']
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
76 """
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
77 for attribute_value in feature.qualifiers.get(kwargs['qualifier'], []):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
78 if attribute_value in kwargs['attribute_list']:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
79 return True
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
80 return False
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
81
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
82
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
83 def __get_features(child, interpro=False):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
84 child_features = {}
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
85 for rec in GFF.parse(child):
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
86 # Only top level
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
87 for feature in rec.features:
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
88 # Get the record id as parent_feature_id (since this is how it will be during remapping)
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
89 parent_feature_id = rec.id
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
90 # If it's an interpro specific gff3 file
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
91 if interpro:
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
92 # Then we ignore polypeptide features as they're useless
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
93 if feature.type == 'polypeptide':
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
94 continue
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
95 # If there's an underscore, we strip up to that underscore?
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
96 # I do not know the rationale for this, removing.
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
97 # if '_' in parent_feature_id:
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
98 # parent_feature_id = parent_feature_id[parent_feature_id.index('_') + 1:]
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
99
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
100 try:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
101 child_features[parent_feature_id].append(feature)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
102 except KeyError:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
103 child_features[parent_feature_id] = [feature]
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
104 # Keep a list of feature objects keyed by parent record id
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
105 return child_features
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
106
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
107
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
108 def __update_feature_location(feature, parent, protein2dna):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
109 start = feature.location.start
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
110 end = feature.location.end
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
111 if protein2dna:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
112 start *= 3
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
113 end *= 3
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
114
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
115 if parent.location.strand >= 0:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
116 ns = parent.location.start + start
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
117 ne = parent.location.start + end
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
118 st = +1
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
119 else:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
120 ns = parent.location.end - end
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
121 ne = parent.location.end - start
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
122 st = -1
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
123
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
124 # Don't let start/stops be less than zero. It's technically valid for them
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
125 # to be (at least in the model I'm working with) but it causes numerous
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
126 # issues.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
127 #
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
128 # Instead, we'll replace with %3 to try and keep it in the same reading
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
129 # frame that it should be in.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
130 if ns < 0:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
131 ns %= 3
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
132 if ne < 0:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
133 ne %= 3
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
134
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
135 feature.location = FeatureLocation(ns, ne, strand=st)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
136
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
137 if hasattr(feature, 'sub_features'):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
138 for subfeature in feature.sub_features:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
139 __update_feature_location(subfeature, parent, protein2dna)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
140
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
141
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
142 def rebase(parent, child, interpro=False, protein2dna=False, map_by='ID'):
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
143 # get all of the features we will be re-mapping in a dictionary, keyed by parent feature ID
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
144 child_features = __get_features(child, interpro=interpro)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
145
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
146 for rec in GFF.parse(parent):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
147 replacement_features = []
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
148 for feature in feature_lambda(
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
149 rec.features,
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
150 # Filter features in the parent genome by those that are
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
151 # "interesting", i.e. have results in child_features array.
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
152 # Probably an unnecessary optimisation.
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
153 feature_test_qual_value,
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
154 {
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
155 'qualifier': map_by,
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
156 'attribute_list': child_features.keys(),
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
157 },
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
158 subfeatures=False):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
159
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
160 # Features which will be re-mapped
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
161 to_remap = child_features[feature.id]
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
162 # TODO: update starts
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
163 fixed_features = []
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
164 for x in to_remap:
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
165 # Then update the location of the actual feature
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
166 __update_feature_location(x, feature, protein2dna)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
167
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
168 if interpro:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
169 for y in ('status', 'Target'):
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
170 try:
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
171 del x.qualifiers[y]
1
ec3646f668e5 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 4a3c9f195ba5d899b1a1ce5e80281cdf230f456a
iuc
parents: 0
diff changeset
172 except Exception:
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
173 pass
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
174
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
175 fixed_features.append(x)
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
176 replacement_features.extend(fixed_features)
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
177 # We do this so we don't include the original set of features that we
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
178 # were rebasing against in our result.
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
179 rec.features = replacement_features
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
180 rec.annotations = {}
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
181 GFF.write([rec], sys.stdout)
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
182
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
183
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
184 if __name__ == '__main__':
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
185 parser = argparse.ArgumentParser(description='rebase gff3 features against parent locations', epilog="")
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
186 parser.add_argument('parent', type=argparse.FileType('r'), help='Parent GFF3 annotations')
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
187 parser.add_argument('child', type=argparse.FileType('r'), help='Child GFF3 annotations to rebase against parent')
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
188 parser.add_argument('--interpro', action='store_true',
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
189 help='Interpro specific modifications')
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
190 parser.add_argument('--protein2dna', action='store_true',
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
191 help='Map protein translated results to original DNA data')
2
8ad4b86dbce1 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 908f16ea4eb082227437dc93e06e8cb742f5a257
iuc
parents: 1
diff changeset
192 parser.add_argument('--map_by', help='Map by key', default='ID')
0
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
193 args = parser.parse_args()
c901b94c7ef7 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/gff3_rebase commit 350ab347625ed5941873ba0deb3e1cf219d60052
iuc
parents:
diff changeset
194 rebase(**vars(args))