[med-svn] [fastaq] 02/03: Imported Upstream version 3.11.0
Sascha Steinbiss
sascha-guest at moszumanska.debian.org
Mon Nov 30 19:46:52 UTC 2015
This is an automated email from the git hooks/post-receive script.
sascha-guest pushed a commit to branch master
in repository fastaq.
commit e83fffbce611f881bbb5f63af44e71a99dc936c0
Author: Sascha Steinbiss <sascha at steinbiss.name>
Date: Mon Nov 30 19:09:05 2015 +0000
Imported Upstream version 3.11.0
---
pyfastaq/common.py | 2 +-
pyfastaq/runners/interleave.py | 10 +++++++++-
pyfastaq/tasks.py | 9 ++++++++-
.../tests/data/sequences_test_deinterleaved_no_suffixes_1.fa | 4 ++++
.../tests/data/sequences_test_deinterleaved_no_suffixes_2.fa | 4 ++++
.../tests/data/sequences_test_interleaved_with_suffixes.fa | 8 ++++++++
pyfastaq/tests/tasks_test.py | 5 +++++
setup.py | 2 +-
8 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/pyfastaq/common.py b/pyfastaq/common.py
index b951f1c..aa6eaf2 100644
--- a/pyfastaq/common.py
+++ b/pyfastaq/common.py
@@ -1 +1 @@
-version = '3.10.1'
+version = '3.11.0'
diff --git a/pyfastaq/runners/interleave.py b/pyfastaq/runners/interleave.py
index 60f2782..4732820 100644
--- a/pyfastaq/runners/interleave.py
+++ b/pyfastaq/runners/interleave.py
@@ -5,8 +5,16 @@ def run(description):
parser = argparse.ArgumentParser(
description = description,
usage = 'fastaq interleave <infile_1> <infile_2> <outfile>')
+ parser.add_argument('--suffix1', help='Suffix to add to all names from infile_1 (if suffix not already present)')
+ parser.add_argument('--suffix2', help='Suffix to add to all names from infile_2 (if suffix not already present)')
parser.add_argument('infile_1', help='Name of first input file')
parser.add_argument('infile_2', help='Name of second input file')
parser.add_argument('outfile', help='Name of output file of interleaved reads')
options = parser.parse_args()
- tasks.interleave(options.infile_1, options.infile_2, options.outfile)
+ tasks.interleave(
+ options.infile_1,
+ options.infile_2,
+ options.outfile,
+ suffix1=options.suffix1,
+ suffix2=options.suffix2
+ )
diff --git a/pyfastaq/tasks.py b/pyfastaq/tasks.py
index e5e1b42..0085b83 100644
--- a/pyfastaq/tasks.py
+++ b/pyfastaq/tasks.py
@@ -354,7 +354,9 @@ def get_seqs_flanking_gaps(infile, outfile, left, right):
utils.close(fout)
-def interleave(infile_1, infile_2, outfile):
+def interleave(infile_1, infile_2, outfile, suffix1=None, suffix2=None):
+ '''Makes interleaved file from two sequence files. If used, will append suffix1 onto end
+ of every sequence name in infile_1, unless it already ends with suffix1. Similar for sufffix2.'''
seq_reader_1 = sequences.file_reader(infile_1)
seq_reader_2 = sequences.file_reader(infile_2)
f_out = utils.open_file_write(outfile)
@@ -366,6 +368,11 @@ def interleave(infile_1, infile_2, outfile):
utils.close(f_out)
raise Error('Error getting mate for sequence', seq_1.id, ' ... cannot continue')
+ if suffix1 is not None and not seq_1.id.endswith(suffix1):
+ seq_1.id += suffix1
+ if suffix2 is not None and not seq_2.id.endswith(suffix2):
+ seq_2.id += suffix2
+
print(seq_1, file=f_out)
print(seq_2, file=f_out)
diff --git a/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_1.fa b/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_1.fa
new file mode 100644
index 0000000..d79df33
--- /dev/null
+++ b/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_1.fa
@@ -0,0 +1,4 @@
+>1/1
+ACGTA
+>2
+A
diff --git a/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_2.fa b/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_2.fa
new file mode 100644
index 0000000..dfe47cd
--- /dev/null
+++ b/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_2.fa
@@ -0,0 +1,4 @@
+>1
+ACGTA
+>2/2
+C
diff --git a/pyfastaq/tests/data/sequences_test_interleaved_with_suffixes.fa b/pyfastaq/tests/data/sequences_test_interleaved_with_suffixes.fa
new file mode 100644
index 0000000..3692716
--- /dev/null
+++ b/pyfastaq/tests/data/sequences_test_interleaved_with_suffixes.fa
@@ -0,0 +1,8 @@
+>1/1
+ACGTA
+>1/2
+ACGTA
+>2/1
+A
+>2/2
+C
diff --git a/pyfastaq/tests/tasks_test.py b/pyfastaq/tests/tasks_test.py
index 3d157ea..e8688b9 100644
--- a/pyfastaq/tests/tasks_test.py
+++ b/pyfastaq/tests/tasks_test.py
@@ -224,6 +224,11 @@ class TestInterleave(unittest.TestCase):
tmp)
self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_interleaved.fa'), tmp))
+ tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_no_suffixes_1.fa'),
+ os.path.join(data_dir, 'sequences_test_deinterleaved_no_suffixes_2.fa'),
+ tmp, suffix1='/1', suffix2='/2')
+ self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_interleaved_with_suffixes.fa'), tmp))
+
with self.assertRaises(tasks.Error):
tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_bad_1.fa'),
os.path.join(data_dir, 'sequences_test_deinterleaved_bad_2.fa'),
diff --git a/setup.py b/setup.py
index baa05ba..39fcf5c 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@ from setuptools import setup, find_packages
setup(
name='pyfastaq',
- version='3.10.1',
+ version='3.11.0',
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