{+ file: cns_to_o.inp +}
{+ directory: general +}
{+ description: Output a coordinate file in a format more suitable for O +}
{+ comment: 
           If the segid is a single character it will be written into the
           chainid column, otherwise the chainid is left blank.
           The spacegroup and cell dimensions will be written at the
           beginning of the file (CRYST1 record). 
           Hydrogen atoms can be removed by the use of the atom selection. +}
{+ authors: Axel T. Brunger, and Paul D. Adams +}
{+ copyright: Yale University +}

{- Guidelines for using this file:
   - all strings must be quoted by double-quotes
   - logical variables (true/false) are not quoted
   - do not remove any evaluate statements from the file -}

{- begin block parameter definition -} define(

{======================= molecular structure =========================}

{* structure file *}
{===>} structure_infile="fab2hfl.mtf";

{* coordinate file *}
{===>} coordinate_infile="fab2hfl.pdb";

{====================== crystallographic data ========================}

{* space group *}
{* use International Table conventions with subscripts substituted
   by parenthesis *}
{===>} sg="P2(1)";

{* unit cell parameters in Angstroms and degrees *}
{+ table: rows=1 "cell" cols=6 "a" "b" "c" "alpha" "beta" "gamma" +}
{===>} a=44.144;
{===>} b=164.69;
{===>} c=70.17;
{===>} alpha=90;
{===>} beta=108.50;
{===>} gamma=90;

{========================== atom selection ===========================}

{* select atoms to be written out *}
{===>} atom_select=(known and not(hydrogen));

{=========================== output files ============================}

{* output coordinate file for O *}
{===>} coordinate_outfile="cns_to_o.pdb";

{===========================================================================}
{        things below this line do not normally need to be changed          }
{===========================================================================}

 ) {- end block parameter definition -}

 checkversion 1.2

 evaluate ($log_level=quiet)

 structure @&structure_infile end

 coordinates @&coordinate_infile

 xray
   @CNS_XTALLIB:spacegroup.lib (sg=&sg;
                                sgparam=$sgparam;)
   a=&a b=&b c=&c  alpha=&alpha beta=&beta gamma=&gamma
 end

 delete selection=(not(&atom_select)) end

 set display=&coordinate_outfile end

 display REMARKS structure file= &STRIP%structure_infile
 display REMARKS coordinate file= &STRIP%coordinate_infile
 display REMARKS spacegroup= &STRIP%sg
 display REMARKS cell: a=&a b=&b c=&c alpha=&alpha beta=&beta gamma=&gamma
 display REMARKS user=$name  date=$date  time=$time

 @CNS_XTALMODULE:write_pdb (pdb_o_format=true;
                            coordinate_outfile=&coordinate_outfile;
                            sgparam=$sgparam;)

 stop