Skip to content

Commit

Permalink
Merge pull request #29 from ginkgobioworks/fix-export
Browse files Browse the repository at this point in the history
Fix export for negative strand
  • Loading branch information
Chris7 committed Feb 12, 2019
2 parents 43b8144 + 5ead19c commit 3b9c728
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
3 changes: 2 additions & 1 deletion src/edge/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
24 changes: 24 additions & 0 deletions src/edge/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,29 @@ def test_outputs_gff(self):
##FASTA
>Bar <unknown description>
%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 <unknown description>
%s
""" % (fragment.sequence,)
self.assertEquals(expected, gff)

0 comments on commit 3b9c728

Please sign in to comment.