-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathXYZRowsGroupData.py
executable file
·58 lines (46 loc) · 1.08 KB
/
XYZRowsGroupData.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
from sys import *
from getopt import getopt
if __name__=='__main__':
programName=argv[0]
opts,args=getopt(argv[1:],'',['remove-self'])
removeSelf=False
for o,v in opts:
if o=="--remove-self":
removeSelf=True
try:
XYZFile=args[0]
group1=args[1]
groups=args[1:]
except:
print >> stderr,programName,"XYZFile [--remove-self] mem1,mem2,mem3 ... ..."
exit(1)
for i in range(0,len(groups)):
groups[i]=groups[i].split(",")
withinGroupZ=[]
notWithinGroupZ=[]
fil=open(XYZFile)
for lin in fil:
X,Y,Z=lin.rstrip("\r\n").split("\t")
withinGroup=False
if removeSelf and X==Y:
continue
for group in groups:
if X in group and Y in group:
withinGroup=True
if withinGroup:
withinGroupZ.append(Z)
else:
notWithinGroupZ.append(Z)
fil.close()
print >> stdout,"within\tnotWithin"
for i in range(0,max(len(withinGroupZ),len(notWithinGroupZ))):
if i>=len(withinGroupZ):
wz=""
else:
wz=withinGroupZ[i]
if i>=len(notWithinGroupZ):
nwz=""
else:
nwz=notWithinGroupZ[i]
print >> stdout,"\t".join([wz,nwz])