All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions | Variables
python.stream Namespace Reference

Functions

def get_stream
 

Variables

tuple stream = get_stream(str(sys.argv[1]))
 

Function Documentation

def python.stream.get_stream (   inputfile)

Definition at line 27 of file stream.py.

27 
28 def get_stream(inputfile):
29 
30  result = ''
31 
32  # Extract sam metadata in form of json string.
33 
34  jobinfo = subprocess.Popen(['sam_metadata_dumper', inputfile],
35  stdout=subprocess.PIPE,
36  stderr=subprocess.PIPE)
37  jobout, joberr = jobinfo.communicate()
38  jobout = convert_str(jobout)
39  joberr = convert_str(joberr)
40  rc = jobinfo.poll()
41  if rc != 0:
42  raise RuntimeError('sam_metadata_dumper failed with status %d' % rc)
43 
44  # Decode json string to dictionary.
45  # Work around art bug by deleting "runs" line.
46 
47  json_str = ''
48  n = jobout.find('"runs"')
49  if n >= 0:
50  m = jobout.rfind('\n', 0, n)
51  if m > 0:
52  json_str = jobout[:m+1]
53  k = jobout.find('\n', n)
54  if k > n:
55  json_str += jobout[k+1:]
56  else:
57  json_str = jobout
58 
59  # End of workaround.
60 
61  js = json.loads(json_str)
62  md = js[inputfile]
63 
64  # Extract stream from json dictionary.
65 
66  if 'data_stream' in md:
67  result = md['data_stream']
68  else:
69  raise RuntimeError('Sam metadata does not contain stream.')
70 
71  # Done.
72 
73  return result
74 
75 # Main program.
def get_stream
Definition: stream.py:27

Variable Documentation

tuple python.stream.stream = get_stream(str(sys.argv[1]))

Definition at line 77 of file stream.py.