localpdb/plugins/utils/MakeMultimer.py
def collate(self):
        '''
        collate all replicated chains into final output
        apply chain renaming and residue renumbering as
        requested
        '''
        # first, assign available letters to chains.
        orig_chains = set()
        for rg in self.replication_groups:
            orig_chains.update(rg.replicated_chains.keys())
        orig_chains = sorted(list(orig_chains))
        # make a generator for each original chain
        # that will supply us with the next chain name
        # and residue offset
        def chain_position_generator(orig_pos):
            chain_list = list(string.ascii_uppercase[orig_pos::len(orig_chains)])
            chain_counter = 0
            while True:
                residue_offset = 0
                for x in range(self.options['renamechains']):
                    yield chain_list[chain_counter], residue_offset
                    residue_offset += self.options['renumberresidues']
                chain_counter += 1
                if chain_counter == len(chain_list):
                    self.overflow_warnings.add(\
                    'Chain name overflow when replicating chain %s' % chain_list[0])
                    chain_counter -= 1  # revert to last available letter

        chain_store = {}
        for pos, chain in enumerate(orig_chains):
            chain_store[chain] = chain_position_generator(pos)

        # should we, or shouldn't we renumber atoms uniquely? we will.
        atom_numbers = dict.fromkeys(string.ascii_uppercase, 0)
        for rg in self.replication_groups:
            for old_chain, chains in sorted(rg.replicated_chains.items()):
                for chain in chains:
                    new_chain, residue_offset = next(chain_store[old_chain])
                    lst = []
                    atom_offset = atom_numbers[new_chain]
                    atom_counter = 0
                    for atom, res_no in chain:
                        # calculate atom number
                        atom_counter += 1
                        new_atom_no = atom_offset + atom_counter
                        if new_atom_no == 100000:
                            self.overflow_warnings.add('Atom number overflow when replicating chain %s' % old_chain)
                            new_atom_no = 1
                        # adjust offset of res_no
                        rn_corrected = res_no + residue_offset
                        if rn_corrected > 9999:
                            self.overflow_warnings.add(\
                              'Residue number overflow when replicating chain %s' % old_chain)
                            rn_corrected = max(1, rn_corrected - 10000)
                        # fill in the atom annotation
                        stuff = (new_atom_no, new_chain, rn_corrected)
                        filled = atom % (new_atom_no, new_chain, rn_corrected)
                        lst.append((new_atom_no, rn_corrected, filled))
                    self.collected_chains.append((old_chain, new_chain, \
                                            lst[0][1], lst[-1][1], \
                                            lst[0][0], lst[-1][0], \
                                            [l[2] for l in lst]))
                    # adjust offset for next time around
                    rounded = int(round(len(chain),-3))
                    if rounded < len(chain):
                        rounded += 1000
                    atom_numbers[new_chain] += rounded

        collate all replicated chains into final output
        apply chain renaming and residue renumbering as
        requested
        
collate all replicated chains into final output
apply chain renaming and residue renumbering as
requested
collate all replicated chains into final output apply chain renaming and residue renumbering as requested
def collate(self):
        orig_chains = set()
        for rg in self.replication_groups:
            orig_chains.update(rg.replicated_chains.keys())
        orig_chains = sorted(list(orig_chains))
        def chain_position_generator(orig_pos):
            chain_list = list(string.ascii_uppercase[orig_pos::len(orig_chains)])
            chain_counter = 0
            while True:
                residue_offset = 0
                for x in range(self.options['renamechains']):
                    yield chain_list[chain_counter], residue_offset
                    residue_offset += self.options['renumberresidues']
                chain_counter += 1
                if chain_counter == len(chain_list):
                    self.overflow_warnings.add(\
                    'Chain name overflow when replicating chain %s' % chain_list[0])
                    chain_counter -= 1  
        chain_store = {}
        for pos, chain in enumerate(orig_chains):
            chain_store[chain] = chain_position_generator(pos)
        atom_numbers = dict.fromkeys(string.ascii_uppercase, 0)
        for rg in self.replication_groups:
            for old_chain, chains in sorted(rg.replicated_chains.items()):
                for chain in chains:
                    new_chain, residue_offset = next(chain_store[old_chain])
                    lst = []
                    atom_offset = atom_numbers[new_chain]
                    atom_counter = 0
                    for atom, res_no in chain:
                        atom_counter += 1
                        new_atom_no = atom_offset + atom_counter
                        if new_atom_no == 100000:
                            self.overflow_warnings.add('Atom number overflow when replicating chain %s' % old_chain)
                            new_atom_no = 1
                        rn_corrected = res_no + residue_offset
                        if rn_corrected > 9999:
                            self.overflow_warnings.add(\
                              'Residue number overflow when replicating chain %s' % old_chain)
                            rn_corrected = max(1, rn_corrected - 10000)
                        stuff = (new_atom_no, new_chain, rn_corrected)
                        filled = atom % (new_atom_no, new_chain, rn_corrected)
                        lst.append((new_atom_no, rn_corrected, filled))
                    self.collected_chains.append((old_chain, new_chain, \
                                            lst[0][1], lst[-1][1], \
                                            lst[0][0], lst[-1][0], \
                                            [l[2] for l in lst]))
                    rounded = int(round(len(chain),-3))
                    if rounded < len(chain):
                        rounded += 1000
                    atom_numbers[new_chain] += rounded
def collate ( self ) : orig_chains = set ( ) for rg in self . replication_groups : orig_chains . update ( rg . replicated_chains . keys ( ) ) orig_chains = sorted ( list ( orig_chains ) ) def chain_position_generator ( orig_pos ) : chain_list = list ( string . ascii_uppercase [ orig_pos : : len ( orig_chains ) ] ) chain_counter = 0 while True : residue_offset = 0 for x in range ( self . options [ 'renamechains' ] ) : yield chain_list [ chain_counter ] , residue_offset residue_offset += self . options [ 'renumberresidues' ] chain_counter += 1 if chain_counter == len ( chain_list ) : self . overflow_warnings . add ( 'Chain name overflow when replicating chain %s' % chain_list [ 0 ] ) chain_counter -= 1 chain_store = { } for pos , chain in enumerate ( orig_chains ) : chain_store [ chain ] = chain_position_generator ( pos ) atom_numbers = dict . fromkeys ( string . ascii_uppercase , 0 ) for rg in self . replication_groups : for old_chain , chains in sorted ( rg . replicated_chains . items ( ) ) : for chain in chains : new_chain , residue_offset = next ( chain_store [ old_chain ] ) lst = [ ] atom_offset = atom_numbers [ new_chain ] atom_counter = 0 for atom , res_no in chain : atom_counter += 1 new_atom_no = atom_offset + atom_counter if new_atom_no == 100000 : self . overflow_warnings . add ( 'Atom number overflow when replicating chain %s' % old_chain ) new_atom_no = 1 rn_corrected = res_no + residue_offset if rn_corrected > 9999 : self . overflow_warnings . add ( 'Residue number overflow when replicating chain %s' % old_chain ) rn_corrected = max ( 1 , rn_corrected - 10000 ) stuff = ( new_atom_no , new_chain , rn_corrected ) filled = atom % ( new_atom_no , new_chain , rn_corrected ) lst . append ( ( new_atom_no , rn_corrected , filled ) ) self . collected_chains . append ( ( old_chain , new_chain , lst [ 0 ] [ 1 ] , lst [ - 1 ] [ 1 ] , lst [ 0 ] [ 0 ] , lst [ - 1 ] [ 0 ] , [ l [ 2 ] for l in lst ] ) ) rounded = int ( round ( len ( chain ) , - 3 ) ) if rounded < len ( chain ) : rounded += 1000 atom_numbers [ new_chain ] += rounded
collate all replicated chains into final output
apply chain renaming and residue renumbering as
requested
collate all replicated chains into final output apply chain renaming and residue renumbering as requested
'''
        collate all replicated chains into final output
        apply chain renaming and residue renumbering as
        requested
        ''' # first, assign available letters to chains. # make a generator for each original chain # that will supply us with the next chain name # and residue offset # revert to last available letter # should we, or shouldn't we renumber atoms uniquely? we will. # calculate atom number # adjust offset of res_no # fill in the atom annotation # adjust offset for next time around
self