Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# -*- coding: latin-1 -*-
'''Take an transcript file from GRO-seq and gets the short transcripts.'''
EPILOG = '''
For more details:
%(prog)s --help
'''
import numpy
import pybedtools
import argparse
import os
from subprocess import Popen
def get_args():
parser = argparse.ArgumentParser(
description=__doc__, epilog=EPILOG,
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument('-t', '--transcripts',
help="The transcripts file defined by gro-seq",
required = True)
args = parser.parse_args()
return args
def main():
args = get_args()
# Read in bedtools:
transcripts = pybedtools.BedTool(args.transcripts)
# Sort if not sorted
transcripts_sorted = transcripts.sort()
# Sepertate into short
short_t = transcripts_sorted.filter(lambda c: c.length <= 9000 and c.length >= 1)
# Save Temp files
short_t.saveas('short_transcripts.bed')
if __name__ == '__main__':
main()