-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from standage/fix/fasta
Fix missing ##FASTA directives, better handling of feature scores
- Loading branch information
Showing
7 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (C) 2017 Daniel Standage <daniel.standage@gmail.com> | ||
# | ||
# This file is part of tag (http://github.com/standage/tag) and is licensed | ||
# under the BSD 3-clause license: see LICENSE. | ||
# ----------------------------------------------------------------------------- | ||
|
||
from __future__ import print_function | ||
import re | ||
|
||
|
||
class Score(object): | ||
|
||
def __init__(self, datastr): | ||
self._type = None | ||
if datastr == '.': | ||
self.value = None | ||
elif re.search('^-*\d+$', datastr): | ||
self.value = int(datastr) | ||
self._type = int | ||
else: | ||
self.value = float(datastr) | ||
self._type = float | ||
|
||
def __str__(self): | ||
if self.value is None: | ||
return '.' | ||
elif self._type == int: | ||
return '{:d}'.format(self.value) | ||
elif abs(self.value) < 1e6 and abs(self.value) > 1e-4: | ||
return '{:1.3f}'.format(self.value) | ||
else: | ||
return '{:1.3E}'.format(self.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env python | ||
# | ||
# ----------------------------------------------------------------------------- | ||
# Copyright (C) 2017 Daniel Standage <daniel.standage@gmail.com> | ||
# | ||
# This file is part of tag (http://github.com/standage/tag) and is licensed | ||
# under the BSD 3-clause license: see LICENSE. | ||
# ----------------------------------------------------------------------------- | ||
|
||
from tag import Score | ||
|
||
|
||
def test_basic(): | ||
for score in ['.', '10', '12.345', '-11', '-98765.432', '-4.555E+09']: | ||
assert str(Score(score)) == score | ||
assert str(Score('10.0')) == '10.000' | ||
assert str(Score('1.32e12')) == '1.320E+12' | ||
assert str(Score('1.2e-16')) == '1.200E-16' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
##gff-version 3 | ||
##sequence-region minimus 1 10 | ||
minimus vim region 4 6 9000 + . Note=lolwut | ||
##FASTA | ||
>minimus | ||
GATTACANNN |