<s> from __future__ import division <EOL> from numpy import zeros <EOL> import re <EOL> def sort_taxa_table_by_pcoa_coords ( coords_header , otu_table , otu_header ) : <EOL> """<STR_LIT>""" <EOL> sorted_otu_headers = [ ] <EOL> matching_headers = len ( set ( coords_header ) & set ( otu_header ) ) <EOL> sorted_otu_table = zeros ( [ otu_table . shape [ <NUM_LIT:0> ] , matching_headers ] ) <EOL> for i , element in enumerate ( coords_header ) : <EOL> if element in otu_header : <EOL> current_index = otu_header . index ( element ) <EOL> sorted_otu_table [ : , i ] = otu_table [ : , current_index ] <EOL> sorted_otu_headers . append ( element ) <EOL> return sorted_otu_headers , sorted_otu_table <EOL> def sort_comparison_filenames ( coord_fps ) : <EOL> """<STR_LIT>""" <EOL> if coord_fps == [ ] : <EOL> return [ ] <EOL> def _get_suffix ( fp ) : <EOL> """<STR_LIT>""" <EOL> regex = re . compile ( r'<STR_LIT>' ) <EOL> tmatch = re . search ( regex , fp ) <EOL> try : <EOL> number = tmatch . group ( <NUM_LIT:2> ) <EOL> except ( IndexError , AttributeError ) : <EOL> number = - <NUM_LIT:1> <EOL> return float ( number ) <EOL> return sorted ( coord_fps , key = _get_suffix ) </s>
