当前位置:  开发笔记 > 编程语言 > 正文

Tcl错误:错误#args:应该是"set varName?newValue?"

如何解决《Tcl错误:错误#args:应该是"setvarName?newValue?"》经验,为你挑选了1个好方法。

我试图运行以下Tcl脚本并得到错误:错误#args:应该是"set varName?newValue?"

这是什么意思?

注意:该脚本包含特定于VMD程序的术语,例如mol和resid.请不要理会他们.

#count water molecules between chain A and chain C or between #chain B and chain C


set input_file [open ./name_3_pdb_chain_renamed.dat r]

set data [read $input_file]
set data [split $data "\n"]
close $input_file

set chain_list [lindex $data 0]

cd 7_count_water

set outfile [open count_water3.dat w]


set chain_compare ""

set pdblen [llength $chain_list]

for {set i 0} {$i<$pdblen} {incr i} {
    set pid [lindex [lindex $chain_list $i] 0]

    set len [llength [lindex $chain_list $i]]

    mol load pdb ../2_chain_rename/${pid}_chain_revised.pdb


    mol modstyle 0 top NewCartoon



    if {$len==4} {
        set chain_compare [lappend chain_compare $pid]
    }

    set 11 [atomselect top all]

    set mid [$11 molid]

    mol delete $mid
}




set lll [llength $chain_compare]

for {set j 0} {$j< $lll} {incr j} {

    set pid [lindex $chain_compare $j]

    mol load pdb ../2_chain_rename/${pid}_chain_revised.pdb

    set 11 [atomselect top "chain A and name CA"]

    set res_len [llength [$11 get resid]]

    set res_id [$11 get resid]

    #residue length for chain C
    set ag [atomselect top "chain C and name CA"]
    set ag_len [llength [$ag get resid]]
    set ag_id [$ag get resid]


    #loop water between chain A and chain C
    for {set k 0} {$k<$res_len} {incr k} {

        set water_around_a [atomselect top "{resname HOH and {within 5.0 of {chain A and resid [lindex $res_id $k]} and {within 5.0 of chain C}}} "]


        set water_around_a_resid [$water_around_a get resid]
        set water_around_a_resname [$water_around_a get resname]

        #loop antigen residues around water
        for {set g 0} {$g < $ag_len} {incr g} {

          set ag_around_water [atomselect top "{chain C and resid [lindex $ag_id $g] and {within 5.0 of {resname HOH and {within 5.0 of {chain A and resid [lindex $res_id $k]}}}}} "]

            set ag_around_water resid [$ag_around_water get resid]

            set ag_around_water_resname [$ag_around_water get resname]


            puts $outfile "$pid [lindex $res_id $k] [lindex [$11 get resname] $k] $ag_around_water_resname A: $water_around_a_resname"
       }
    }



    set b11 [atomselect top "chain B and name CA"]

    set b_res_len [llength [$b11 get resid]]

    set b_res_id [$b11 get resid]

    #residue length for chain C
    set ag [atomselect top "chain C and name CA"]
    set ag_len [llength [$ag get resid]]
    set ag_id [$ag get resid]

    for {set k 0} {$k<$res_len} {incr k} {


        set water_around_b [atomselect top "{resname HOH and {within 5.0 of {chain B and resid [lindex $b_res_id $k]} and {within 5.0 of chain C}}} "]

        set water_around_b_resid [$water_around_b get resid]
        set water_around_b_resname [$water_around_b get resname]

        #loop antigen residues around water
        for {set g 0} {$g < $ag_len} {incr g} {

             set ag_around_water [atomselect top "{chain C and resid [lindex $ag_id $g] and {within 5.0 of {resname HOH and {within 5.0 of {chain B and resid [lindex $b_res_id $k]}}}}} "]


            set ag_around_water resid [$ag_around_water get resid]

            set ag_around_water_resname [$ag_around_water get resname]

            puts $outfile "$pid [lindex $b_res_id $k] [lindex [$b11 get resname] $k] $ag_around_water_resname A: $water_around_b_resname"


        }

    }

}


close $outfile

cd ..

谢谢



1> Donal Fellow..:

那条消息:

wrong # args: should be "set varName ?newValue?"

是内置命令获取要评估的错误数量的参数时引发的标准错误.在这种情况下,它来自set命令,并表示您已经单独说出set,或者给出了两个以上的进一步参数.

如果您检查堆栈跟踪(通常在使用标准时打印错误消息tclsh,尽管可以使用用户代码更改),那么您将被告知问题发生的位置.但是,在这种情况下,我们可以查看并看到脚本底部附近的这一行:

            set ag_around_water resid [$ag_around_water get resid]

在变量名中有一个空格而不是下划线.现在,空格在变量名称中合法的,但随后需要引用变量名称,这可能会有点烦人.通常最好避免像这样使用它们.没有引用,Tcl不知道那是一个单词; 通用解析层决定没什么四个字有(set,ag_around_water,resid和复杂的[$ag_around_water get resid]),并告诉set对付的是,它不喜欢.

请记住,在语义解释命令参数之前,首先发生Tcl的通用语法分析.总是.

推荐阅读
赛亚兔备_393
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有