From de9df1fd0ff309cd18f31f348302a663efa8fdd0 Mon Sep 17 00:00:00 2001 From: Chris Mitchell Date: Tue, 12 Feb 2019 13:01:36 -0500 Subject: [PATCH 1/3] Fix export for negative strand --- src/edge/io.py | 3 ++- src/edge/tests/test_io.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) 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) From f7db6d66809598ea27df5bc107131414964d0878 Mon Sep 17 00:00:00 2001 From: Chris Mitchell Date: Tue, 12 Feb 2019 13:50:43 -0500 Subject: [PATCH 2/3] Add django to setup.py setup_reqs --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index 3b05a042..014a5d48 100644 --- a/setup.py +++ b/setup.py @@ -126,6 +126,9 @@ def run(self): setup_requires=[ 'django_assets >= 0.12', + # This has to be installed here because django_assets tries to install Django>=1.7 and will + # force install Django2+ in setup + 'Django ~= 1.11.6', ], install_requires=[ 'django ~= 1.11.6', From 5ead19c98b5e6c51bb44bec1b4aaff13d8c8ec61 Mon Sep 17 00:00:00 2001 From: Chris Mitchell Date: Tue, 12 Feb 2019 14:17:48 -0500 Subject: [PATCH 3/3] Fix flake --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 014a5d48..e0c983c9 100644 --- a/setup.py +++ b/setup.py @@ -124,10 +124,10 @@ 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', - # This has to be installed here because django_assets tries to install Django>=1.7 and will - # force install Django2+ in setup 'Django ~= 1.11.6', ], install_requires=[