Hi Jordan et al.,

Yes one can use the alter command with a whole selection at once and
it is much faster. I hadn't realized that until Thomas Holder helped fix
my script that appears to do what you were wanting to do:

 http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/data2bfactor.py

The B-factor data is read in and assigned to a dictionary by the
"atom_data_extract" function elsewhere in the script (indexed either by
chain and residue number, or by chain and ID) and then it is applied
like this:

    b_dict = atom_data_extract(data_file)
    quiet = int(quiet) == 1

    def b_lookup(chain, resi, name, ID, b):
        def _lookup(chain, resi, name, ID):
            if resi in b_dict[chain] and isinstance(b_dict[chain][resi], dict):
                return b_dict[chain][resi][name][0]
            else:
                # find data by ID
                return b_dict[chain][int(ID)][0]
        try:
            if not chain in b_dict:
                chain = ''
            b = _lookup(chain, resi, name, ID)
            if not quiet: print '///%s/%s/%s new: %f' % (chain, resi, name, b)
        except KeyError:
            if not quiet: print '///%s/%s/%s keeping: %f' % (chain, resi, name, 
b)
        return b
    stored.b = b_lookup

    cmd.alter(mol, '%s=stored.b(chain, resi, name, ID, %s)' % (prop, prop))
    cmd.rebuild()

Hope that helps.

Cheers,
Rob

On Tue, 2015-06-16 11:10 EDT, Tsjerk Wassenaar <tsje...@gmail.com>
wrote:

> Hi Jordan,
> 
> The answer is something like (assuming reading from a file):
> 
> newb=[float(i) for i in open("stuff.dat").read().split()]
> alter n. ca, b=newb.pop()
> spectrum b
> 
> Hope it helps,
> 
> Tsjerk
> 
> On Tue, Jun 16, 2015 at 10:25 AM, Jordan Willis
> <jwillis0...@gmail.com> wrote:
> 
> > Hi Tsjerk,
> >
> > It seems everyone is pointing to this (
> > http://www.pymolwiki.org/index.php/Color#Reassigning_B-Factors_and_Coloring)
> > which I somehow missed. However, they seem to be altering one
> > residue at a time like I’m doing.
> >
> >
> > Jordan
> >
> > On Jun 15, 2015, at 11:59 PM, Tsjerk Wassenaar <tsje...@gmail.com>
> > wrote:
> >
> > Hi Jordan,
> >
> > Yes, although I don't have the answer at hand, it has been given on
> > the user list several times. You can find it in the archives.
> >
> > Cheers,
> >
> > Tsjerk
> > On Jun 16, 2015 08:16, "Jordan Willis" <jwillis0...@gmail.com>
> > wrote:
> >
> >> Hi,
> >>
> >> I have a dictionary that has a bunch of values I want to assign to
> >> b-factors in order to color by. In my script:
> >>
> >> for residue in data:
> >>    cmd.alter(“resi
> >> {}”.format(residue[‘resnum’]),”b={}”.format(residue[‘value’]))
> >>
> >> This executes the alter command for each residue. For some reason,
> >> its taking forever in my script. Is there something inherently
> >> inefficient about alter? And is there anyway to fix it? Perhaps,
> >> assign a bunch of b-factors at once.
> >>
> >> Jordan
> >>
> >>
> >> ------------------------------------------------------------------------------
> >>
> >> _______________________________________________
> >> PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
> >> Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
> >> Archives:
> >> http://www.mail-archive.com/pymol-users@lists.sourceforge.net
> >>
> >
> >
> 
> 




-- 
Robert L. Campbell, Ph.D.
Senior Research Associate/Adjunct Assistant Professor
Dept. of Biomedical & Molecular Sciences, Botterell Hall Rm 644
Queen's University, 
Kingston, ON K7L 3N6  Canada
Tel: 613-533-6821
<robert.campb...@queensu.ca>  http://pldserver1.biochem.queensu.ca/~rlc

------------------------------------------------------------------------------
_______________________________________________
PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net)
Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net

Reply via email to