예제 #1
0
    def test_sample_seq(self):
        sample_seq = os.path.join(BIN_DIR, 'sample_seqs')
        assert 'usage' in check_output([sample_seq, '-h'])

        fasta_fhand = NamedTemporaryFile()
        fasta_fhand.write('>seq\nACTA\n>seq2\nACTA\n>seq3\nACTA\n')
        fasta_fhand.flush()

        # random sample
        result = check_output([sample_seq, '-n', '1', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 1

        # random sample
        result = check_output([sample_seq, '-n', '2', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2

        # random sample
        try:
            stderr = NamedTemporaryFile()
            check_output([sample_seq, '-n', '10', fasta_fhand.name],
                         stderr=stderr)
        except CalledProcessError:
            assert 'larger' in open(stderr.name).read()

        # random sample with stdin
        result = check_output([sample_seq, '-n', '2'],
                              stdin=open(fasta_fhand.name))
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2
예제 #2
0
    def test_sample_seq(self):
        sample_seq = os.path.join(BIN_DIR, 'sample_seqs')
        assert 'usage' in check_output([sample_seq, '-h'])

        fasta_fhand = NamedTemporaryFile()
        fasta_fhand.write('>seq\nACTA\n>seq2\nACTA\n>seq3\nACTA\n')
        fasta_fhand.flush()

        # random sample
        result = check_output([sample_seq, '-n', '1', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 1

        # random sample
        result = check_output([sample_seq, '-n', '2', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2

        # random sample
        try:
            stderr = NamedTemporaryFile()
            check_output([sample_seq, '-n', '10', fasta_fhand.name],
                         stderr=stderr)
        except CalledProcessError:
            assert 'larger' in open(stderr.name).read()

        # random sample with stdin
        result = check_output([sample_seq, '-n', '2'],
                              stdin=open(fasta_fhand.name))
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2
예제 #3
0
 def test_count_seqs():
     in_fhands = []
     for val in range(1, 6):
         fhand = open(join(TEST_DATA_DIR, 'pairend{0}.sfastq'.format(val)))
         in_fhands.append(fhand)
     seqs = read_seqs(in_fhands, prefered_seq_classes=[SEQRECORD])
     counts = count_seqs(seqs)
     assert counts == {'total_length': 96, 'num_seqs': 24}
예제 #4
0
 def test_count_seqs():
     in_fhands = []
     for val in range(1, 6):
         fhand = open(join(TEST_DATA_DIR, 'pairend{0}.sfastq'.format(val)))
         in_fhands.append(fhand)
     seqs = read_seqs(in_fhands, prefered_seq_classes=[SEQRECORD])
     counts = count_seqs(seqs)
     assert counts == {'total_length': 96, 'num_seqs': 24}
예제 #5
0
    def test_sample_seq(self):
        'It tests the seq head'
        sample_seq = os.path.join(BIN_DIR, 'sample_seqs')
        assert 'usage' in check_output([sample_seq, '-h'])

        fasta_fhand = NamedTemporaryFile()
        fasta_fhand.write('>seq\nACTA\n>seq2\nACTA\n>seq3\nACTA\n')
        fasta_fhand.flush()

        # random sample
        result = check_output([sample_seq, '-n', '1', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 1

        # random sample
        result = check_output([sample_seq, '-n', '2', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2

        # random sample with stdin
        result = check_output([sample_seq, '-n', '2'],
                              stdin=open(fasta_fhand.name))
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2
예제 #6
0
    def test_sample_seq(self):
        'It tests the seq head'
        sample_seq = os.path.join(BIN_DIR, 'sample_seqs')
        assert 'usage' in check_output([sample_seq, '-h'])

        fasta_fhand = NamedTemporaryFile()
        fasta_fhand.write('>seq\nACTA\n>seq2\nACTA\n>seq3\nACTA\n')
        fasta_fhand.flush()

        # random sample
        result = check_output([sample_seq, '-n', '1', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 1

        # random sample
        result = check_output([sample_seq, '-n', '2', fasta_fhand.name])
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2

        # random sample with stdin
        result = check_output([sample_seq, '-n', '2'],
                              stdin=open(fasta_fhand.name))
        assert count_seqs(read_seqs([StringIO(result)]))['num_seqs'] == 2