-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsortBeds.py
More file actions
43 lines (37 loc) · 823 Bytes
/
Copy pathsortBeds.py
File metadata and controls
43 lines (37 loc) · 823 Bytes
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
40
41
42
#!/usr/bin/env python3
# Name: Bryan Thornlow
# Date: 6/6/2017
# makeHiConfBeds.py
import sys
import os
import time
import random
import numpy
import gzip
import math
def sortBeds():
myOutString = ''
startToLine = {}
for line in open(str(sys.argv[1])):
splitLine = (line.strip()).split('\t')
startToLine[int(splitLine[1])] = splitLine
for k in sorted(startToLine.keys()):
myOutString += joiner(startToLine[k])+'\n'
open(str(sys.argv[1]),'w').write(myOutString)
def joiner(entry):
"""
Helper function to print lists in
tab separated format.
"""
newList = []
for k in entry:
newList.append(str(k))
return '\t'.join(newList)
def main():
sortBeds()
if __name__ == "__main__":
"""
Calls main when program is run by user.
"""
main();
raise SystemExit