def multiple_file_normalize_CSS(input_dir, output_dir, output_CSS_statistics):
 if (not exists(output_dir)):
  makedirs(output_dir)
 file_names = [fname for fname in listdir(input_dir) if (not (fname.startswith('.') or isdir(fname)))]
 for fname in file_names:
  (base_fname, ext) = splitext(fname)
  original_fname = (base_fname + '.biom')
  hdf5_infile = join(input_dir, original_fname)
  tmp_bt = load_table(hdf5_infile)
  outfile = join(output_dir, (('CSS_' + base_fname) + '.biom'))
  if output_CSS_statistics:
   output_CSS_statistics = join(output_dir, (('CSS_statistics_' + base_fname) + '.txt'))
  with tempfile.NamedTemporaryFile(dir=get_qiime_temp_dir(), prefix='QIIME-normalize-table-temp-table-', suffix='.biom') as temp_fh:
   temp_fh.write(tmp_bt.to_json('forR'))
   temp_fh.flush()
   run_CSS(temp_fh.name, outfile, output_CSS_statistics=output_CSS_statistics)

def multiple_file_normalize_CSS ( input_dir , output_dir , output_CSS_statistics ) : if ( not exists ( output_dir ) ) : makedirs ( output_dir ) file_names = [ fname for fname in listdir ( input_dir ) if ( not ( fname . startswith ( '.' ) or isdir ( fname ) ) ) ] for fname in file_names : ( base_fname , ext ) = splitext ( fname ) original_fname = ( base_fname + '.biom' ) hdf5_infile = join ( input_dir , original_fname ) tmp_bt = load_table ( hdf5_infile ) outfile = join ( output_dir , ( ( 'CSS_' + base_fname ) + '.biom' ) ) if output_CSS_statistics : output_CSS_statistics = join ( output_dir , ( ( 'CSS_statistics_' + base_fname ) + '.txt' ) ) with tempfile . NamedTemporaryFile ( dir = get_qiime_temp_dir ( ) , prefix = 'QIIME-normalize-table-temp-table-' , suffix = '.biom' ) as temp_fh : temp_fh . write ( tmp_bt . to_json ( 'forR' ) ) temp_fh . flush ( ) run_CSS ( temp_fh . name , outfile , output_CSS_statistics = output_CSS_statistics )
performs metagenomeseqs css normalization on a directory of raw abundance otu matrices .