From: Axel Kohlmeyer (akohlmey_at_gmail.com)
Date: Thu May 31 2012 - 15:57:33 CDT
On Thu, May 31, 2012 at 4:20 PM, Ajith Rathnaweera Rajapaksha Mudalige
<arajapak_at_purdue.edu> wrote:
> Hi All,
>
> I am in need to write an output file in pdb format at the stage of simulation in progress.
>
> In order to simply present my requirement I have invented the following trivial case.
>
> I am running a simulation to open a pdb file and write another file using the data in the first pdb file exactly following the pdb format.
>
> I have shown below my TCL script. This script work fine. But, when I look at the output I see 2 problems.
> 1) Records are not separated into lines
> 2) Each record is included within curly brackets
each of the two issues are due to improper Tcl scripting.
to address 1) why don't you just write each line as you process it?
to address 2) why don't you use the "format" command?
axel.
>
> -------------------------------------------------------------------
> set file1 [open "output_from_targets.pdb" w]
>
> set duplicate {}
>
> set inStream [open ubq_protein_only_2.pdb r]
>
> foreach line [split [read $inStream] \n] {
> set rec_name [string range $line 0 5]
> set atm_ID [string range $line 6 10]
> set atm_name [string range $line 12 15]
> set res_name [string range $line 17 19]
> set chain_ID [string range $line 21 21]
> set res_ID [string range $line 21 25]
> set x_coord [string range $line 30 37]
> set y_coord [string range $line 38 47]
> set z_coord [string range $line 46 53]
> set occupancy [string range $line 54 59]
> set beta [string range $line 60 65]
> set seg_name [string range $line 72 75]
> set Element [string range $line 76 77]
>
> if { ($beta == 1)} {
> lappend targets "[string trim $rec_name] [string trim $atm_ID] [string trim $atm_name] [string trim $res_name] [string trim $chain_ID] [string trim $res_ID] [string trim $x_coord] [string trim $y_coord] [string trim $z_coord] [string trim $occupancy] [string trim $beta] [string trim $seg_name] [string trim $Element]"
> }
> }
>
> close $inStream
>
> puts $file1 $duplicate
> ----------------------------------------------------------------
>
> I appreciate any useful comment to rectify the problems I am having.
>
> Thanks in advance.
>
> Ajith
>
-- Dr. Axel Kohlmeyer akohlmey_at_gmail.com http://goo.gl/1wk0 College of Science and Technology Temple University, Philadelphia PA, USA.
This archive was generated by hypermail 2.1.6 : Mon Dec 31 2012 - 23:21:36 CST