def multiple_file_nmds(input_dir, output_dir, dimensions=2):
 if (not os.path.exists(output_dir)):
  os.makedirs(output_dir)
 file_names = os.listdir(input_dir)
 file_names = [fname for fname in file_names if (not fname.startswith('.'))]
 for fname in file_names:
  (base_fname, ext) = os.path.splitext(fname)
  infile = os.path.join(input_dir, fname)
  lines = open(infile, 'U')
  nmds_res_string = nmds(lines, dimensions)
  outfile = os.path.join(output_dir, (('nmds_' + base_fname) + '.txt'))
  outfile = open(outfile, 'w')
  outfile.write(nmds_res_string)
  outfile.close()

def multiple_file_nmds ( input_dir , output_dir , dimensions = 2 ) : if ( not os . path . exists ( output_dir ) ) : os . makedirs ( output_dir ) file_names = os . listdir ( input_dir ) file_names = [ fname for fname in file_names if ( not fname . startswith ( '.' ) ) ] for fname in file_names : ( base_fname , ext ) = os . path . splitext ( fname ) infile = os . path . join ( input_dir , fname ) lines = open ( infile , 'U' ) nmds_res_string = nmds ( lines , dimensions ) outfile = os . path . join ( output_dir , ( ( 'nmds_' + base_fname ) + '.txt' ) ) outfile = open ( outfile , 'w' ) outfile . write ( nmds_res_string ) outfile . close ( )
perform pcoas on all distance matrices in the input_dir .