def NexusIterator(handle, seq_count=None):
 n = Nexus.Nexus(handle)
 if (not n.matrix):
  raise StopIteration
 assert (len(n.unaltered_taxlabels) == len(n.taxlabels))
 if (seq_count and (seq_count != len(n.unaltered_taxlabels))):
  raise ValueError(('Found %i sequences, but seq_count=%i' % (len(n.unaltered_taxlabels), seq_count)))
 records = (SeqRecord(n.matrix[new_name], id=new_name, name=old_name, description='') for (old_name, new_name) in zip(n.unaltered_taxlabels, n.taxlabels))
 (yield MultipleSeqAlignment(records, n.alphabet))

def NexusIterator ( handle , seq_count = None ) : n = Nexus . Nexus ( handle ) if ( not n . matrix ) : raise StopIteration assert ( len ( n . unaltered_taxlabels ) == len ( n . taxlabels ) ) if ( seq_count and ( seq_count != len ( n . unaltered_taxlabels ) ) ) : raise ValueError ( ( 'Found %i sequences, but seq_count=%i' % ( len ( n . unaltered_taxlabels ) , seq_count ) ) ) records = ( SeqRecord ( n . matrix [ new_name ] , id = new_name , name = old_name , description = '' ) for ( old_name , new_name ) in zip ( n . unaltered_taxlabels , n . taxlabels ) ) ( yield MultipleSeqAlignment ( records , n . alphabet ) )
returns seqrecord objects from a nexus file .