def remove_outliers(seqs, num_stds, fraction_seqs_for_stats=0.95):
 aln = Alignment.from_fasta_records(parse_fasta(seqs), DNA)
 consensus_seq = aln.majority_consensus()
 dists_to_consensus = [s.distance(consensus_seq) for s in aln]
 average_distance = mean(dists_to_consensus)
 std_distance = std(dists_to_consensus)
 dist_cutoff = (average_distance + (num_stds * std_distance))
 seqs_to_keep = []
 for (seq_id, dist_to_consensus) in izip(aln.ids(), dists_to_consensus):
  if (dist_to_consensus <= dist_cutoff):
   seqs_to_keep.append(seq_id)
 filtered_aln = aln.subalignment(seqs_to_keep=seqs_to_keep)
 return filtered_aln

def remove_outliers ( seqs , num_stds , fraction_seqs_for_stats = 0.95 ) : aln = Alignment . from_fasta_records ( parse_fasta ( seqs ) , DNA ) consensus_seq = aln . majority_consensus ( ) dists_to_consensus = [ s . distance ( consensus_seq ) for s in aln ] average_distance = mean ( dists_to_consensus ) std_distance = std ( dists_to_consensus ) dist_cutoff = ( average_distance + ( num_stds * std_distance ) ) seqs_to_keep = [ ] for ( seq_id , dist_to_consensus ) in izip ( aln . ids ( ) , dists_to_consensus ) : if ( dist_to_consensus <= dist_cutoff ) : seqs_to_keep . append ( seq_id ) filtered_aln = aln . subalignment ( seqs_to_keep = seqs_to_keep ) return filtered_aln
remove sequences very different from the majority consensus given aligned sequences .