diff --git a/setup.py b/setup.py index 3b05a042..e0c983c9 100644 --- a/setup.py +++ b/setup.py @@ -124,8 +124,11 @@ def run(self): include_package_data=True, zip_safe=True, + # Django has to be specified here because django_assets tries to install Django>=1.7 and will + # force install Django2+ in setup setup_requires=[ 'django_assets >= 0.12', + 'Django ~= 1.11.6', ], install_requires=[ 'django ~= 1.11.6', diff --git a/src/edge/io.py b/src/edge/io.py index a9826450..e2b938cb 100644 --- a/src/edge/io.py +++ b/src/edge/io.py @@ -40,9 +40,10 @@ def to_gff_file(self, file): # FeatureLocation first bp is AfterPosition, so -1 loc = FeatureLocation(annotation.base_first - 1, annotation.base_last) qualifiers = {'name': annotation.feature.name} + strand = annotation.feature.strand feature = SeqFeature(loc, type=annotation.feature.type, - strand=1, + strand=0 if strand is None else strand, qualifiers=qualifiers) features.append(feature) diff --git a/src/edge/tests/test_io.py b/src/edge/tests/test_io.py index 80ef0d94..b01b5e89 100644 --- a/src/edge/tests/test_io.py +++ b/src/edge/tests/test_io.py @@ -51,5 +51,29 @@ def test_outputs_gff(self): ##FASTA >Bar %s +""" % (fragment.sequence,) + self.assertEquals(expected, gff) + + def test_outputs_gff_handles_negative_strand(self): + fragment = self.fragment.indexed_fragment() + fragment.annotate(2, 9, 'A1', 'gene', -1) + fragment.insert_bases(3, 'gataca') + + with tempfile.NamedTemporaryFile(mode='rw+', delete=False) as f: + f.close() + IO(self.genome).to_gff(f.name) + h = open(f.name, 'r') + gff = h.read() + h.close() + os.unlink(f.name) + + # be aware of the tabs in the string below + expected = """##gff-version 3 +##sequence-region Bar 1 19 +Bar\tfeature\tgene\t2\t2\t.\t-\t.\tname=A1 +Bar\tfeature\tgene\t9\t15\t.\t-\t.\tname=A1 +##FASTA +>Bar +%s """ % (fragment.sequence,) self.assertEquals(expected, gff)