CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NewTree.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # go to the tree file and pick out all the paths that have hits greater
4 # than the cutoff and convert the entries to edge definitions.
5 
6 import sys
7 import re
8 import Parameters
9 import operator
10 import string
11 
12 def runme2(fid,infile,outfile):
13  fin = open(infile,'r')
14  fout = open(outfile,'w')
15  sub = ' ' + fid + '[ $]'
16  r = re.compile(sub)
17 
18  for line in fin.xreadlines():
19  i = line.index(' ')+1
20  s = r.search(line[i:])
21  if s != None:
22  print >>fout,line[0:i+s.end()-1]
23 
24 def runme(fid,infile,outfile):
25  fin = open(infile,'r')
26  fout = open(outfile,'w')
27  tot_up = Parameters.parameters['view']['levels_up']
28  tot_down = Parameters.parameters['view']['levels_down']
29  print "up=",tot_up," down=",tot_down
30  # trigger too difficult for now
31  trigger = Parameters.parameters['find']['immediate_children_threshold']
32 
33  for line in fin.xreadlines():
34  a=line.split()
35  b=a[2:]
36  # find fid in a
37  try:
38  i=operator.indexOf(b,fid)
39  # write out stuff according to tot_up and tot_down
40  if i < tot_up: c = i
41  else: c = tot_up
42  print >>fout,"%s %s %s"%(a[0],a[1],string.join(b[i-c:i+1+tot_down]))
43  except ValueError:
44  pass
45 
46 if __name__ == "__main__":
47  if len(sys.argv) < 3:
48  print "usage: ", sys.argv[0], " function_id input_file_prefix"
49  sys.exit(1)
50 
51  fid = sys.argv[1]
52  infile = sys.argv[2]
53  outfile = fid + Parameters.parameters['view']['out_file_suffix']
54  runme(fid, infile, outfile)
55 
def runme2
Definition: NewTree.py:12
def runme
Definition: NewTree.py:24