TABLE OF CONTENTS


::pwtk::smi2xsf

SYNOPSIS

proc ::pwtk::smi2xsf {args} {

USAGE

   smi2image ?-d?  ?-vacuum VACUUM|-box BOX_SPECS?  SMILES  ?OUTPUT_XSF?

PURPOSE

Convert SMILES specs to XSF formatted structure data.

A molecular XSF data is created unless the -vacuum or -box options are specified, in which case a 3D XSF data are created.

If the OUTPUT_XSF argument is given, the XSF data are written to the OUTPUT_XSF file.

OPTIONS

Display option:

Exclusive options:

       + if BOX_SPECS == A: cubic box (A x A x A),
       + if BOX_SPECS == {A C}: tetragonal box (A x A x C),
       + if BOX_SPECS == {A B C}: orthorhombic (A x B x C).

ARGUMENTS

RETURN VALUE

SOURCE

    set nargmin 1
    set nargmax 2
    set usage "?-d?  SMILES  ?OUTPUT_XSF?"
    set options {
        {d  "display the generated image"}
        {vacuum.arg -8.0 "size of vacuum around the molecule in angstroms (the same in each direction)"}
        {box.arg    -1   "size of the box in angstroms used for the CELL_PARAMETERS"}
    }
    parseOpt_
    checkOTypeStrict_ -vacuum $opt(vacuum) double number
    checkOTypeStrict_ -box    $opt(box)    {numberlist double}  "list of numbers"

    lassign $args smiles xsf
    
    # check if both -vacuum & -box were specified
    set lvac [expr {"-vacuum" in $args_}]
    set lbox [expr {"-box" in $args_}]
    if { $lvac + $lbox > 1 } {
        ::pwtk::error "-vacuum & -box exclusive options were specified; please specify only one of them" 1
    }
    
    set coor [smilesToCoor $smiles]
    set nat  [getNAtoms $coor]

    if { $lvac } {
        lassign [boxify $coor $opt(vacuum)] A B C
    } elseif { $lbox } {
        # assume orthorhomic: A B C
        lassign $opt(box) A B C
        if { $B eq {} } {
            # cubic: A A A
            set C [set B $A]
        } elseif { $C eq {} } {
            # tetragonal: A A C
            set C $B
            set B $A
        }
    }

    # XSF
    
    ifempty A {
        set result "MOLECULE"
    } else {
        set result "CRYSTAL\n
PRIMVEC
$A   0.0  0.0
0.0  $B   0.0
0.0  0.0  $C"
    }
    append result "\n\nPRIMCOORD\n$nat 1\n$coor"
    ifnotempty xsf {
        writeFile $xsf $result
    }

    # visualize
    
    if { $opt(d) } {
        ifempty xsf {
            set xsf [::fileutil::tempfile].xsf
            writeFile $xsf $result
        }
        try_exec -i xcrysden --xsf $xsf
    }
    
    return $result
}