Awesome, thanks so much Jared for your usefull suggestions!

all the best

james

вт, 25 июн. 2019 г. в 22:00, Jared Sampson <jared.samp...@columbia.edu>:
>
> Hi James - Glad you got it working.
>
> > chains_array = ["A", "B"]
>
> If you want a list of chains without having to hard-code them, try the 
> `get_chains` command.
>
> ```
> chains_array = cmd.get_chains()
> ```
>
> > cmd.load('${pdb}')
> > cmd.alter('chain ' + '+'.join(chains_array), 'chain=\"\"')
>
> Alternatively, if you want to remove all the chain IDs (which it appears you 
> might), you don't need a list of chains at all, and can just do:
>
> ```
> alter all, chain=''
> ```
>
> Hope that helps.
>
> Cheers,
> Jared
>
>
> On June 25, 2019 at 11:48:32 AM, James Starlight (jmsstarli...@gmail.com) 
> wrote:
>
> I have got it, it works now!
> in my example the double quotes were not escaped in pymol script :-)
>
> the only (more python-oriented) question, would it be possible to
> indicate chains_array for all letters A-Z (e.g. using some python
> regex, rather just for A and B, chains_array = ["A", "B"], like in my
> example?
>
>
> вт, 25 июн. 2019 г. в 17:22, James Starlight <jmsstarli...@gmail.com>:
> >
> > I actually tried to do like that still defining chains_array = ["A",
> > "B"] inside of pymol script and use external bash loop to loop over
> > pdbs
> > but it does not works ;(
> >
> > #!/bin/bash
> > # this script rename chains in pdb to "empty" chain
> > home=$(pwd)
> > pdb_folder=$home/pdbs
> > output=$home/output
> > rm -r $output
> > mkdir $output
> >
> > #pymol -cQkd "
> > for pdb in "${pdb_folder}"/*.pdb ; do
> > pdb_name2=$(basename "${pdb}")
> > pdb_name="${pdb_name2/pdb}"
> > pymol -c -d "
> > from pymol import cmd
> > chains_array = ["A", "B"]
> > cmd.load('${pdb}')
> > cmd.alter('chain ' + '+'.join(chains_array), 'chain=\"\"')
> > cmd.set('pdb_use_ter_records', 1)
> > cmd.set('retain_order', 1)
> > cmd.save('${output}/output_without'+"".join(chains_array) + '.pdb')
> > " > $output/pymol_${pdb_name}.log
> > done
> >
> > вт, 25 июн. 2019 г. в 16:58, James Starlight <jmsstarli...@gmail.com>:
> > >
> > > yes, actually it is better because we avoid looping!
> > > and how it would be possible to use array provided in the externall shell?
> > >
> > > #!/bin/bash
> > > pdb="final.pdb"
> > > output=$(pwd)
> > >
> > > # array given in bash
> > > chains_array=('A' 'B')
> > >
> > > # chains are cutted by pymol
> > > pymol -c -d "
> > > cmd.load('${pdb}')
> > > cmd.alter('chain ' + '+'.join($chains_array), 'chain=\"\"')
> > > cmd.set('pdb_use_ter_records', 1)
> > > cmd.set('retain_order', 1)
> > > cmd.save('output_without'+"".join($chains_array) + '.pdb')
> > > "
> > >
> > > вт, 25 июн. 2019 г. в 16:47, Thomas Holder 
> > > <thomas.hol...@schrodinger.com>:
> > > >
> > > > If you want to rename multiple chains at once, make a selection like 
> > > > (chain A+B+C). This list selection syntax is documented here: 
> > > > https://pymolwiki.org/index.php/Property_Selectors
> > > >
> > > > cmd.load(pdb)
> > > > cmd.alter('chain ' + '+'.join(chains_array), 'chain=""')
> > > > cmd.save('output.pdb')
> > > >
> > > > Cheers,
> > > > Thomas
> > > >
> > > >
> > > > > On Jun 25, 2019, at 4:14 PM, James Starlight <jmsstarli...@gmail.com> 
> > > > > wrote:
> > > > >
> > > > > thanks so much Thomas, for this example!
> > > > >
> > > > > Actually, your python script does exactly what my bash script -
> > > > > produces number of pdbs for each of the renamed chain.
> > > > > I would like rather to produce at the end ONE pdb with all chains
> > > > > renamed to empty chain...
> > > > > I guess I need to save the result outside of the loop something like 
> > > > > this
> > > > >
> > > > > ################ hop hey lalaley #####
> > > > > from pymol import cmd
> > > > > pdb = "Ev_complex_model_final.pdb"
> > > > > chains_array = ["A", "B"] # add more chains in case of more complex 
> > > > > pdb
> > > > >
> > > > > # loop over chains to rename it
> > > > > for chain in chains_array:
> > > > > cmd.load(pdb)
> > > > > cmd.alter('chain ' + chain, 'chain=""')
> > > > > cmd.delete('*')
> > > > > ######################################
> > > > >
> > > > > # save output as pdb
> > > > > # I need to add something in the name of output indicating how much
> > > > > chains have been renamed
> > > > > # like output_withoutAB.pdb
> > > > > cmd.save('output_' + '.pdb')
> > > > >
> > > > > thanks in advance for help!
> > > >
> > > > --
> > > > Thomas Holder
> > > > PyMOL Principal Developer
> > > > Schrödinger, Inc.
> > > >
>
>
> _______________________________________________
> PyMOL-users mailing list
> Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
> Unsubscribe: 
> https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe


_______________________________________________
PyMOL-users mailing list
Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net
Unsubscribe: 
https://sourceforge.net/projects/pymol/lists/pymol-users/unsubscribe

Reply via email to