def stackarray(data, sample):
<EOL>sample, _, _, nhidepth, maxlen = recal_hidepth(data, sample)<EOL>clusters = gzip.open(sample.files.clusters)<EOL>pairdealer = itertools.izip(*[iter(clusters)]*<NUM_LIT:2>)<EOL>dims = (nhidepth, maxlen, <NUM_LIT:4>)<EOL>stacked = np.zeros(dims, dtype=np.uint64)<EOL>cutlens = [None, None]<EOL>try:<EOL><INDENT>cutlens[<NUM_LIT:0>] = len(data.paramsdict["<STR_LIT>"][<NUM_LIT:0>])<EOL>cutlens[<NUM_LIT:1>] = maxlen - len(data.paramsdict["<STR_LIT>"][<NUM_LIT:1>])<EOL><DEDENT>except TypeError:<EOL><INDENT>pass<EOL><DEDENT>nclust = <NUM_LIT:0><EOL>done = <NUM_LIT:0><EOL>while not done:<EOL><INDENT>try:<EOL><INDENT>done, chunk = clustdealer(pairdealer, <NUM_LIT:1>)<EOL><DEDENT>except IndexError:<EOL><INDENT>raise IPyradError("<STR_LIT>", chunk)<EOL><DEDENT>if chunk:<EOL><INDENT>piece = chunk[<NUM_LIT:0>].strip().split("<STR_LIT:\n>")<EOL>names = piece[<NUM_LIT:0>::<NUM_LIT:2>]<EOL>seqs = piece[<NUM_LIT:1>::<NUM_LIT:2>]<EOL>reps = [int(sname.split("<STR_LIT:;>")[-<NUM_LIT:2>][<NUM_LIT:5>:]) for sname in names]<EOL>sseqs = [list(seq) for seq in seqs]<EOL>arrayed = np.concatenate(<EOL>[[seq]*rep for seq, rep in zip(sseqs, reps)])<EOL>if arrayed.shape[<NUM_LIT:0>] >= data.paramsdict["<STR_LIT>"]:<EOL><INDENT>arrayed = arrayed[:<NUM_LIT>, cutlens[<NUM_LIT:0>]:cutlens[<NUM_LIT:1>]]<EOL>arrayed = arrayed[:, ~np.any(arrayed == "<STR_LIT:n>", axis=<NUM_LIT:0>)]<EOL>arrayed[arrayed == "<STR_LIT:->"] = "<STR_LIT:N>"<EOL>arrayed = arrayed[:, ~np.all(arrayed == "<STR_LIT:N>", axis=<NUM_LIT:0>)]<EOL>catg = np.array([np.sum(arrayed == i, axis=<NUM_LIT:0>) for i in list("<STR_LIT>")], <EOL>dtype=np.uint64).T<EOL>stacked[nclust, :catg.shape[<NUM_LIT:0>], :] = catg<EOL>nclust += <NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>newstack = stacked[stacked.sum(axis=<NUM_LIT:2>) > <NUM_LIT:0>]<EOL>assert not np.any(newstack.sum(axis=<NUM_LIT:1>) == <NUM_LIT:0>), "<STR_LIT>"<EOL>clusters.close()<EOL>return newstack<EOL>
Stacks clusters into arrays