Esempio n. 1
0
 def test_iter_stream(self):
     progress = MockProgress()
     xphyle.configure(progress=True, progress_wrapper=progress)
     with intercept_stdin('foo\nbar\nbaz'):
         with xopen(STDIN, 'rt', context_wrapper=True,
                    compression=False) as o:
             lines = list(o)
             self.assertListEqual(['foo\n', 'bar\n', 'baz\n'], lines)
     assert 3 == progress.count
Esempio n. 2
0
 def test_progress(self):
     progress = MockProgress()
     xphyle.configure(progress=True, progress_wrapper=progress)
     path = self.root.make_file()
     with open(path, 'wt') as o:
         for i in range(100):
             o.write(random_text())
     compress_file(path, compression='gz', use_system=False)
     assert 100 == progress.count
Esempio n. 3
0
 def test_progress_delmited(self):
     progress = MockProgress()
     xphyle.configure(progress=True, progress_wrapper=progress)
     path = self.root.make_file()
     with open(path, 'wt') as o:
         for i in range(100):
             o.write('row\t{}\n'.format(i))
     rows = list(read_delimited(path))
     assert 100 == len(rows)
     assert 100 == progress.count
Esempio n. 4
0
#!/usr/local/bin/python

import os, warnings, argparse, gzip, tqdm, xphyle
from Bio import SeqIO
from sys import argv
from Bio.Seq import Seq
from mimetypes import guess_type
from functools import partial
from xphyle import xopen

xphyle.configure(progress=True)
xphyle.configure(threads=4)


def rreplace(s, old, new, occurrence):
    li = s.rsplit(old, occurrence)
    return new.join(li)


def translate(fasta):
    dbf = os.path.basename(rreplace(fasta, 'fasta', 'fasta.db', 1))
    print('Translating...')
    with xopen(dbf, 'wt') as db:
        parser = SeqIO.parse(xopen(fasta, 'rt'), 'fasta')
        for sequence in parser:
            id, seq = sequence.description, Seq(
                str(sequence.seq).upper().replace('X', 'N'))
            f = (-3, -2, -1, 1, 2, 3)
            for i in f:
                if i < 0:
                    db.write('>%s\n%s\n' %
Esempio n. 5
0
 def setUp(self):
     self.root = TempDir()
     xphyle.configure(progress=False)