def jplace_split(self, original_jplace, cluster_dict):
output_hash = {}<EOL>for placement in original_jplace['<STR_LIT>']: <EOL><INDENT>alias_placements_list = []<EOL>nm_dict = {}<EOL>p = placement['<STR_LIT:p>']<EOL>if '<STR_LIT>' in placement.keys():<EOL><INDENT>nm = placement['<STR_LIT>']<EOL><DEDENT>elif '<STR_LIT:n>' in placement.keys():<EOL><INDENT>nm = placement['<STR_LIT:n>']<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>for nm_entry in nm:<EOL><INDENT>nm_list = []<EOL>placement_read_name, plval = nm_entry<EOL>read_alias_idx = placement_read_name.split('<STR_LIT:_>')[-<NUM_LIT:1>] <EOL>read_name = '<STR_LIT:_>'.join(placement_read_name.split('<STR_LIT:_>')[:-<NUM_LIT:1>])<EOL>read_cluster = cluster_dict[read_alias_idx][read_name]<EOL>for read in read_cluster:<EOL><INDENT>nm_list.append([read.name, plval])<EOL><DEDENT>if read_alias_idx not in nm_dict:<EOL><INDENT>nm_dict[read_alias_idx] = nm_list<EOL><DEDENT>else:<EOL><INDENT>nm_dict[read_alias_idx] += nm_entry<EOL><DEDENT><DEDENT>for alias_idx, nm_list in nm_dict.iteritems():<EOL><INDENT>placement_hash = {'<STR_LIT:p>': p,<EOL>'<STR_LIT>': nm_list}<EOL>if alias_idx not in output_hash:<EOL><INDENT>output_hash[alias_idx] = [placement_hash]<EOL><DEDENT>else:<EOL><INDENT>output_hash[alias_idx].append(placement_hash)<EOL><DEDENT><DEDENT><DEDENT>return output_hash<EOL>
To make GraftM more efficient, reads are dereplicated and merged into
one file prior to placement using pplacer. This function separates the
single jplace file produced by this process into the separate jplace
files, one per input file (if multiple were provided) and backfills
abundance (re-replicates?) into the placement file so analyses can be
done using the placement files.

Parameters
----------
original_jplace : dict (json)
    json .jplace file from the pplacer step.
cluster_dict : dict
    dictionary stores information on pre-placement clustering

Returns
-------
A dict containing placement hashes to write to
new jplace file. Each key represents a file alias