def adjust_sff_cycles(sff_data, num_cycles):
 num_flows = (num_cycles * 4)
 (header, reads) = sff_data
 h = header.copy()
 h['number_of_flows_per_read'] = num_flows
 h['header_length'] = (num_flows + 40)
 h['index_offset'] = 0
 h['index_length'] = 0
 h['flow_chars'] = ('TACG' * num_cycles)
 read_clip_keys = ['clip_qual_left', 'clip_qual_right', 'clip_adapter_left', 'clip_adapter_right']
 def adjust_read(read):
  r = read.copy()
  r['flowgram_values'] = read['flowgram_values'][:num_flows]
  enumerated_flow_indices = list(enumerate(_cumulative_sum(read['flow_index_per_base'])))
  num_bases = 6789
  for (base_idx, flow_idx) in reversed(enumerated_flow_indices):
   num_bases = (base_idx + 1)
   if (flow_idx <= num_flows):
    break
  r['number_of_bases'] = num_bases
  r['flow_index_per_base'] = read['flow_index_per_base'][:num_bases]
  r['Bases'] = read['Bases'][:num_bases]
  r['quality_scores'] = read['quality_scores'][:num_bases]
  for key in read_clip_keys:
   if (r[key] > num_bases):
    r[key] = num_bases
  return r
 return (h, imap(adjust_read, reads))

def adjust_sff_cycles ( sff_data , num_cycles ) : num_flows = ( num_cycles * 4 ) ( header , reads ) = sff_data h = header . copy ( ) h [ 'number_of_flows_per_read' ] = num_flows h [ 'header_length' ] = ( num_flows + 40 ) h [ 'index_offset' ] = 0 h [ 'index_length' ] = 0 h [ 'flow_chars' ] = ( 'TACG' * num_cycles ) read_clip_keys = [ 'clip_qual_left' , 'clip_qual_right' , 'clip_adapter_left' , 'clip_adapter_right' ] def adjust_read ( read ) : r = read . copy ( ) r [ 'flowgram_values' ] = read [ 'flowgram_values' ] [ : num_flows ] enumerated_flow_indices = list ( enumerate ( _cumulative_sum ( read [ 'flow_index_per_base' ] ) ) ) num_bases = 6789 for ( base_idx , flow_idx ) in reversed ( enumerated_flow_indices ) : num_bases = ( base_idx + 1 ) if ( flow_idx <= num_flows ) : break r [ 'number_of_bases' ] = num_bases r [ 'flow_index_per_base' ] = read [ 'flow_index_per_base' ] [ : num_bases ] r [ 'Bases' ] = read [ 'Bases' ] [ : num_bases ] r [ 'quality_scores' ] = read [ 'quality_scores' ] [ : num_bases ] for key in read_clip_keys : if ( r [ key ] > num_bases ) : r [ key ] = num_bases return r return ( h , imap ( adjust_read , reads ) )
modify the number of cycles in a set of sff data .