def testPrefixSuffix(self):
     seq = '>hey\nagtccgatcg'
     trimmed_seq = '>hey\nccga'
     result = trimReads(3, 3, StringIO(seq))
     test_result = list(SeqIO.parse(StringIO(trimmed_seq), 'fasta'))
     self.assertEqual(list(map(str, tuple(result))),
                      list(map(str, tuple(test_result))))
 def testPrefixSuffix(self):
     seq = '>hey\nagtccgatcg'
     trimmed_seq = '>hey\nccga'
     result = trimReads(3, 3, StringIO(seq))
     test_result = list(SeqIO.parse(StringIO(trimmed_seq), 'fasta'))
     self.assertEqual(list(map(str, tuple(result))),
                      list(map(str, tuple(test_result))))
 def testOneInput(self):
     result = trimReads(10, 10, StringIO())
     test_result = list(SeqIO.parse(StringIO(), 'fasta'))
     self.assertEqual(list(map(str, tuple(result))),
                      list(map(str, tuple(test_result))))
 def testOneInput(self):
     result = trimReads(10, 10, StringIO())
     test_result = list(SeqIO.parse(StringIO(), 'fasta'))
     self.assertEqual(list(map(str, tuple(result))),
                      list(map(str, tuple(test_result))))
#!/usr/bin/env python

from Bio import SeqIO
from dark.analyze_reads import getPrefixAndSuffix
from dark.analyze_reads import trimReads
import sys


if len(sys.argv) != 2:
    print >> sys.stderr, "getPrefixAndSuffix() takes exactly 1 argument"
    sys.exit(1)

else:
    filename = sys.argv[1]
    prefix, suffix = getPrefixAndSuffix(filename)

    print >>sys.stderr, "Prefix length %d, suffix length %d" % (prefix, suffix)

    SeqIO.write(trimReads(prefix, suffix, filename), sys.stdout, 'fasta')
#!/usr/bin/env python

from __future__ import print_function

from Bio import SeqIO
from dark.analyze_reads import getPrefixAndSuffix
from dark.analyze_reads import trimReads
import sys


if len(sys.argv) != 2:
    print('getPrefixAndSuffix() takes exactly 1 argument', file=sys.stderr)
    sys.exit(1)

else:
    filename = sys.argv[1]
    prefix, suffix = getPrefixAndSuffix(filename)

    print('Prefix length %d, suffix length %d' % (prefix, suffix),
          file=sys.stderr)

    SeqIO.write(trimReads(prefix, suffix, filename), sys.stdout, 'fasta')
 def testLongPrefixSuffix(self):
     seq = ">hey\nagtccgatcg"
     trimmed_seq = ">hey\n"
     result = trimReads(8, 4, StringIO(seq))
     test_result = list(SeqIO.parse(StringIO(trimmed_seq), "fasta"))
     self.assertEqual(map(str, tuple(result)), map(str, tuple(test_result)))
 def testZeroInput(self):
     result = trimReads(0, 0, StringIO())
     test_result = list(SeqIO.parse(StringIO(), "fasta"))
     self.assertEqual(map(str, tuple(result)), map(str, tuple(test_result)))