[med-svn] [fastaq] 01/03: Imported Upstream version 3.11.1
Sascha Steinbiss
sascha at steinbiss.name
Tue Jan 5 10:21:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
sascha-guest pushed a commit to branch master
in repository fastaq.
commit 5b178b352cd7933a74d68041e6e9e02b6304ce4b
Author: Sascha Steinbiss <sascha at steinbiss.name>
Date: Tue Jan 5 10:14:25 2016 +0000
Imported Upstream version 3.11.1
---
README.md | 2 +-
pyfastaq/common.py | 2 +-
pyfastaq/sequences.py | 24 +++++++++++++++++-------
pyfastaq/tests/sequences_test.py | 6 ++++++
scripts/fastaq | 2 +-
setup.py | 2 +-
6 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 269ddc8..46f0828 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ Available commands
| interleave | Interleaves two files, output is alternating between fwd/rev reads |
| make_random_contigs | Make contigs of random sequence |
| merge | Converts multi sequence file to a single sequence |
-| replace_bases | Replaces all occurences of one letter with another |
+| replace_bases | Replaces all occurrences of one letter with another |
| reverse_complement | Reverse complement all sequences |
| scaffolds_to_contigs | Creates a file of contigs from a file of scaffolds |
| search_for_seq | Find all exact matches to a string (and its reverse complement) |
diff --git a/pyfastaq/common.py b/pyfastaq/common.py
index aa6eaf2..e27854a 100644
--- a/pyfastaq/common.py
+++ b/pyfastaq/common.py
@@ -1 +1 @@
-version = '3.11.0'
+version = '3.11.1'
diff --git a/pyfastaq/sequences.py b/pyfastaq/sequences.py
index fdffc60..f757719 100644
--- a/pyfastaq/sequences.py
+++ b/pyfastaq/sequences.py
@@ -248,7 +248,7 @@ class Fasta:
self.seq = ''.join(new_seq)
def replace_bases(self, old, new):
- '''Replaces all occurences of 'old' with 'new' '''
+ '''Replaces all occurrences of 'old' with 'new' '''
self.seq = self.seq.replace(old, new)
def replace_interval(self, start, end, new):
@@ -288,9 +288,11 @@ class Fasta:
return [intervals.Interval(coords[i], coords[i+1]) for i in range(0, len(coords)-1,2)]
-
-
def orfs(self, frame=0, revcomp=False):
+ '''Returns a list of ORFs that the sequence has, starting on the given
+ frame. Each returned ORF is an interval.Interval object.
+ If revomp=True, then finds the ORFs of the reverse complement
+ of the sequence.'''
assert frame in [0,1,2]
if revcomp:
self.revcomp()
@@ -314,6 +316,11 @@ class Fasta:
def all_orfs(self, min_length=300):
+ '''Finds all open reading frames in the sequence, that are at least as
+ long as min_length. Includes ORFs on the reverse strand.
+ Returns a list of ORFs, where each element is a tuple:
+ (interval.Interval, bool)
+ where bool=True means on the reverse strand'''
orfs = []
for frame in [0,1,2]:
for revcomp in [False, True]:
@@ -335,10 +342,13 @@ class Fasta:
return False
- def looks_like_gene(self, translation_table=1):
+ def looks_like_gene(self):
'''Returns true iff: length >=6, length is a multiple of 3, first codon is start, last codon is a stop and has no other stop codons'''
- return self.is_complete_orf() and len(self) >= 6 and len(self) %3 == 0 and self.seq[0:3] in genetic_codes.starts[genetic_code]
-
+ return self.is_complete_orf() \
+ and len(self) >= 6 \
+ and len(self) %3 == 0 \
+ and self.seq[0:3].upper() in genetic_codes.starts[genetic_code]
+
# Fills the object with the next sequence in the file. Returns
# True if this was successful, False if no more sequences in the file.
@@ -399,7 +409,7 @@ class Fasta:
return Fastq(self.id, self.seq, ''.join([chr(max(0, min(x, 93)) + 33) for x in qual_scores]))
def search(self, search_string):
- '''Finds every occurence (including overlapping ones) of the search_string, including on the reverse strand. Returns a list where each element is a tuple (position, strand) where strand is in ['-', '+']. Positions are zero-based'''
+ '''Finds every occurrence (including overlapping ones) of the search_string, including on the reverse strand. Returns a list where each element is a tuple (position, strand) where strand is in ['-', '+']. Positions are zero-based'''
seq = self.seq.upper()
search_string = search_string.upper()
pos = 0
diff --git a/pyfastaq/tests/sequences_test.py b/pyfastaq/tests/sequences_test.py
index 51e8e2e..8663422 100644
--- a/pyfastaq/tests/sequences_test.py
+++ b/pyfastaq/tests/sequences_test.py
@@ -252,6 +252,7 @@ class TestFasta(unittest.TestCase):
tests = [
(sequences.Fasta('ID', 'TTT'), False),
(sequences.Fasta('ID', 'TTGTAA'), True),
+ (sequences.Fasta('ID', 'ttgTAA'), True),
(sequences.Fasta('ID', 'TTGTTTTAA'), True),
(sequences.Fasta('ID', 'TTGTAATTTTAA'), False),
(sequences.Fasta('ID', 'TTGTTTTGAA'), False),
@@ -260,6 +261,11 @@ class TestFasta(unittest.TestCase):
for t in tests:
self.assertEqual(t[0].looks_like_gene(), t[1])
+ sequences.genetic_code = 1
+ self.assertFalse(sequences.Fasta('ID', 'ATTCAGTAA').looks_like_gene())
+ sequences.genetic_code = 11
+ self.assertTrue(sequences.Fasta('ID', 'ATTCAGTAA').looks_like_gene())
+
def test_is_all_Ns(self):
'''Test is_all_Ns()'''
diff --git a/scripts/fastaq b/scripts/fastaq
index b264517..cffaf4b 100755
--- a/scripts/fastaq
+++ b/scripts/fastaq
@@ -19,7 +19,7 @@ tasks = {
'interleave': 'Interleaves two files, output is alternating between fwd/rev reads',
'make_random_contigs': 'Make contigs of random sequence',
'merge': 'Converts multi sequence file to a single sequence',
- 'replace_bases': 'Replaces all occurences of one letter with another',
+ 'replace_bases': 'Replaces all occurrences of one letter with another',
'reverse_complement': 'Reverse complement all sequences',
'scaffolds_to_contigs': 'Creates a file of contigs from a file of scaffolds',
'search_for_seq': 'Find all exact matches to a string (and its reverse complement)',
diff --git a/setup.py b/setup.py
index 39fcf5c..f20b8a1 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
setup(
name='pyfastaq',
- version='3.11.0',
+ version='3.11.1',
description='Script to manipulate FASTA and FASTQ files, plus API for developers',
packages = find_packages(),
author='Martin Hunt',
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/fastaq.git
More information about the debian-med-commit
mailing list