{"id":27213371,"url":"https://github.com/anjibabuiitk/cluster-analysis-using-vmd-tcl","last_synced_at":"2026-01-26T12:38:24.112Z","repository":{"id":189761252,"uuid":"115731582","full_name":"anjibabuIITK/CLUSTER-ANALYSIS-USING-VMD-TCL","owner":"anjibabuIITK","description":"Kapakayala Anji Babu , IIT Kanpur, India.","archived":false,"fork":false,"pushed_at":"2018-08-10T03:27:03.000Z","size":426,"stargazers_count":6,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-08-21T17:25:32.651Z","etag":null,"topics":["analysis","clustering","perform","script","tcl","to","vmd"],"latest_commit_sha":null,"homepage":"https://anjibabuiitk.github.io/CLUSTER-ANALYSIS-USING-VMD-TCL/","language":"Tcl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anjibabuIITK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-12-29T15:07:45.000Z","updated_at":"2023-08-21T17:25:36.627Z","dependencies_parsed_at":"2023-08-21T17:25:34.906Z","dependency_job_id":null,"html_url":"https://github.com/anjibabuIITK/CLUSTER-ANALYSIS-USING-VMD-TCL","commit_stats":null,"previous_names":["anjibabuiitk/cluster-analysis-using-vmd-tcl"],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anjibabuIITK%2FCLUSTER-ANALYSIS-USING-VMD-TCL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anjibabuIITK%2FCLUSTER-ANALYSIS-USING-VMD-TCL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anjibabuIITK%2FCLUSTER-ANALYSIS-USING-VMD-TCL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anjibabuIITK%2FCLUSTER-ANALYSIS-USING-VMD-TCL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anjibabuIITK","download_url":"https://codeload.github.com/anjibabuIITK/CLUSTER-ANALYSIS-USING-VMD-TCL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248144857,"owners_count":21054999,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analysis","clustering","perform","script","tcl","to","vmd"],"created_at":"2025-04-10T02:40:39.589Z","updated_at":"2026-01-26T12:38:24.079Z","avatar_url":"https://github.com/anjibabuIITK.png","language":"Tcl","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **CLUSTER-ANALYSIS-USING-VMD-TCL**\n\n**TCL VMD SCRIPT TO DO CLUSTER ANALYSIS**\n\n     Authour : ANJI BABU KAPAKYALA,\n               Dept. of Chemistry,\n               C/O Dr.Nisanth N.Nair,\n               IIT KANPUR, INDIA.\n             (anjibabu480@gmail.com)\n\n    \n    PURPOSE : To Perform the cluster analysis\n    \n    USAGE   : source clustering.tcl in VMD Tk console.\n         : clustering {Atomselection} {rmsd_cutoff} {step size} {frame_args}\n\n **Arguments   :**\n \n     Atomselect  : Any atom selection\n \n     rmsd_cutoff : RMSD cutoff\n \n     Step_size   : STEP SIZE ( nothing but skip)\n \n     frame_args  : Initial \u0026 final frame numbers\n  \n **Default Arguments :**\n \n     Dist_func         : Distance Function is set to rmsd as default.\n \n     num               : No. of Clusters are fixed to default vaule 3\n\n **EXAMPLES :**\n            \n     EXAMPLE1 : clustering \"(protein) and backbone\" 1.0 2\n     EXAMPLE2 : clustering \"(protein) and backbone\" 1.0 2 5\n     EXAMPLE3 : clustering \"(protein) and backbone\" 1.0 2 5 25\n \n **Example1**, measures the clusters of given selections with rmsd cutoff 1.0 and \n           step size 2 for zeroth frame to final frame in trajectory.\n \n **Example2**, measures the clusters of given selections with rmsd cutoff 1.0 and \n           step size 2 from frame 5 to final frame in trajectory.\n \n **Example3**, measures the clusters of given selections with rmsd cutoff 1.0 and\n           step size 2 from frame 5 to frame 25 in trajectory.\n \n (At present No. of clusters are fixed to 3)\n Default Distance function is rmsd. but you can change to fitrmsd or rgyd or rmsd\n\n**OUTPUT FILES :** \nIt shows the clusters on New graphical representation and stores the data in 4 files as well.\n\n    CLUSTER-A.pdb\n    CLUSTER-B.pdb\n    CLUSTER-C.pdb\n    UNCLUSTER.pdb\n    cluster.log\n\n**EXAMPLE OUTPUT of this code looks like this. ( on Tk console)**\n#===================================================================#\n\n    WELCOME TO CLUSTERING ANALYSIS PLUGIN \n  ----------------------------------------\n \n    No. of frames Found in Trajectory: 99\n\n\n    Given Data :\n    =============\n\n    Atomselection     : (protein) and backbone \n    Distance Function : rmsd (default) \n    No. of clusters   : 3    (default) \n    Rmsd Cutoff       : 1.0      \n    Step size         : 2 \n    Starting Frame    : 0 \n    End Frame         : 99 \n\n    Analysis will be performed on 0 to 99 frame(s) \n\n    CLUSTER-A (41) :\n    18 0 2 8 10 12 14 16 20 22 24 26 28 30 32 34 36 38 40......etc \n\n    CLUSTER-B (4)  :\n     94 90 92 96 \n\n    CLUSTER-C (2)  :\n    4 6 \n\n    UNCLUSTRED (2) : \n    64 82\n\n \n    Writing OUTPUT files.........\n\n    10 %    20 %    30 %    40 %    50 %    60 %    70 %    80 %    90 %    100 %      \n\n    OUTPUT files :\n    ---------------\n    CLUSTER-A.pdb\n    CLUSTER-B.pdb\n    CLUSTER-C.pdb \n    UNCLUSTER.pdb \n    cluster.log\n\n\n**TCL Code :**\n\n```tcl\n    \nproc clustering {sel1 rcutoff step_size args } {\n#=====================Allignment=====================================\nset n [molinfo top get numframes]\nfor {set i 0} {$i \u003c= $n} {incr i} {\nset ref_sel [ atomselect top  \"protein and backbone\" frame 0]\nset compare_sel [ atomselect top \"protein and backbone\" frame $i]\nset transform_matrx [ measure fit $compare_sel $ref_sel ]\n$compare_sel  move $transform_matrx\n}\nputs \"Aligned w.r.t protein backbone\"\n#=====================CLUSTERING==================================\n#puts -nonewline \"\\nEnter Your Selction :\"\n#flush stdout\n#gets stdin sel\n#puts \"$sel\"\n#-----default number of clusters\nset number 3\n#---------------------------------------#\nset nframes [molinfo top get numframes]\n#---------------Opening OUTPUT files\nset file1 [open \"CLUSTER-A.pdb\" w]\nset file2 [open \"CLUSTER-B.pdb\" w]\nset file3 [open \"CLUSTER-C.pdb\" w]\nset file4 [open \"UNCLUSTER.pdb\" w]\nset logfile [open \"cluster.log\" w]\nputs $logfile \"\\n Aligned w.r.t protein backbone \\n\"\n#---------------Settingup arguments----#\n  set sel $sel1\n  set selA [atomselect top $sel ]\n#---------------frames details----------#\n  if {[llength $args] == 0} {\n      set inf 0\n      set nf $nframes\n}\n if {[llength $args] == 1} {\n    set inf [lindex $args 0]\n    set nf $nframes\n  }\n  if {[llength $args] \u003e 1} {\n    set inf [lindex $args 0]\n    set nf [lindex $args 1]\n    }\n#------------------total frames---------#\n  set totframes [expr $nf - 1 ]\n#------------------PRINT Given DATA-----#\n puts \" \\n \\t  \\t  WELCOME TO CLUSTERING ANALYSIS PLUGIN \"\n puts \"    \\t  \\t  =====================================\\n\\n\"\n puts \" \\n No. of frames Found in Trajectory: $nframes\\n\\n\"\n puts \" Given Data :\\n =============\\n\"\n puts \" Atomselection     : $sel1 \"\n puts \" Distance Function : rmsd (default) \"\n puts \" No. of clusters   : 3    (default) \"\n puts \" Rmsd Cutoff       : $rcutoff      \"\n puts \" Step size         : $step_size \"\n puts \" Starting Frame    : $inf \"\n puts \" End Frame         : $nf \\n\"\n puts \" Analysis will be performed on $inf to $nframes frame(s) \\n\\n\\n\"\n#------------------------------------------#\n#------------------PRINT Given DATA in logfile-----#\n puts $logfile \" \\n \\t  \\t  WELCOME TO CLUSTERING ANALYSIS PLUGIN \"\n puts $logfile \"    \\t  \\t  =====================================\\n\\n\"\n puts $logfile \" \\n No. of frames Found in Trajectory: $nframes\\n\\n\"\n puts $logfile \" Given Data :\\n =============\\n\"\n puts $logfile \" Atomselection     : $sel1 \"\n puts $logfile \" Distance Function : rmsd (default) \"\n puts $logfile \" No. of clusters   : 3    (default) \"\n puts $logfile \" Rmsd Cutoff       : $rcutoff      \"\n puts $logfile \" Step size         : $step_size \"\n puts $logfile \" Starting Frame    : $inf \"\n puts $logfile \" End Frame         : $nf \\n\"\n puts $logfile \" Analysis will be performed on $inf to $nframes frame(s) \\n\\n\\n\"\n#------------------------------------------#\n  # Cluster\n  #set result [measure cluster $selA num $number cutoff $rmsdcutoff first 0 last $totframes  step 2 distfunc rmsd ]\n#selupdate $calc_selupdate weight $calc_weight]\n#  set nclusters [llength $result]\n#  puts \"$nclusters\"\n#----------------------------------------\n# foreach {listA listB listC listD} [measure cluster $selA num $number cutoff $rmsdcutoff first $inf last $totframes  step 1 distfunc rmsd ] break\n foreach {listA listB listC listD} [measure cluster $selA num $number cutoff $rcutoff first $inf last $totframes  step $step_size distfunc rmsd ] break\n    set nclustera [llength $listA] ; set nclusterb [llength $listB] ; set nclusterc [llength $listC] ; set nclusterd [llength $listD]\n puts \" CLUSTER-A ($nclustera) :\\n $listA \\n\\n CLUSTER-B ($nclusterb)  :\\n $listB \\n\\n CLUSTER-C ($nclusterc)  :\\n $listC \\n\\n UNCLUSTRED ($nclusterd) : \\n $listD\\n\"\n puts $logfile  \" CLUSTER-A ($nclustera) :\\n $listA \\n\\n CLUSTER-B ($nclusterb)  :\\n $listB \\n\\n CLUSTER-C ($nclusterc)  :\\n $listC \\n\\n UNCLUSTRED ($nclusterd) : \\n $listD\\n\"\n#-----------------------------------------------\n# update on graphical representation of the above clusters\n#------ListA\nmenu graphics on\n#mol delrep replica_number Mol_number\nmol delrep 0 0\nmol delrep 0 0\nmol delrep 0 0\nmol delrep 0 0\nmol representation lines\nmol selection $sel\nmol addrep 0\nmol drawframes 0 0 $listA\nmol modcolor 0 0 ColorID 0\n#------ListAB\nmol representation lines\nmol selection $sel\nmol addrep 0\nmol drawframes 0 1 $listB\nmol modcolor 1 0 ColorID 1\n#------ListC\nmol representation lines\nmol selection $sel\nmol addrep 0\nmol drawframes 0 2 $listC\nmol modcolor 2 0 ColorID 4\n#------ListD\nmol representation lines\nmol selection $sel\nmol addrep 0\nmol drawframes 0 3 $listD\nmol modcolor 3 0 ColorID 7\nmol showrep 0 2 0\nmol showrep 0 0\n#mol showrep 0 2 1\n#mol showrep 0 2 0\n#---------------WRITING OUTPUT----------------------------------------\nputs \" \\n Writing OUTPUT files.........\\n\"\n#--------------------Cycle starts\nfor {set i 0 ; set d 1} { $i\u003c=$nframes} {incr i; incr d}  {\n#------------------STATUS BAR\n# show activity\n#    if { [expr $d % 10] == 0 } {\n#doble (number) gives floating point\n     set percentage [expr double($d)*100/double($totframes )]\n#int(number) gives intger\n    if { [expr int($percentage) % 10 ] == 0 } {\n      puts -nonewline \" [expr int($percentage)] %     \"\n flush stdout\n     }\n#   if { [expr $d % 500] == 0 } { puts \" \" }\n#    flush stdout\n#   }\n#-------STORING CLUSTER-A\n  foreach list1 $listA {\n    if {$i == $list1 } {\n#puts \" Writing CLUSTER-A.xyz :$i\"\n#puts \"$i : $list1 \"\n#set selA [atomselect top $sel frame $i ]\n[atomselect top \"all\" frame $i] writepdb cluster$i.pdb\nexec cat cluster$i.pdb \u003e\u003e CLUSTER-A.pdb\nexec rm cluster$i.pdb\n}\n}\n#-------STORING CLUSTER-B\n  foreach list2 $listB {\n    if {$i == $list2 } {\n#puts \"$i : $list2 \"\n#puts \" Writing CLUSTER-B.xyz :$i\"\n#set selA [atomselect top $sel frame $i ]\n[atomselect top \"all\" frame $i] writepdb cluster$i.pdb\nexec cat cluster$i.pdb \u003e\u003e CLUSTER-B.pdb\nexec rm cluster$i.pdb\n}\n}\n#-------STORING CLUSTER-C\n  foreach list3 $listC {\n    if {$i == $list3 } {\n#puts \"$i : $list3 \"\n#puts \" Writing CLUSTER-C.xyz :$i\"\n#set selA [atomselect top $sel frame $i ]\n[atomselect top \"all\" frame $i] writepdb cluster$i.pdb\nexec cat cluster$i.pdb \u003e\u003e CLUSTER-C.pdb\nexec rm cluster$i.pdb\n}\n}\n#-------STORING UN CLUSTER-D\n  foreach list4 $listD {\n    if {$i == $list4 } {\n#puts \"$i : $list4 \"\n#puts \" Writing UNCLUSTER.xyz :$i\"\n#set selA [atomselect top $sel frame $i ]\n[atomselect top \"all\" frame $i] writepdb cluster$i.pdb\nexec cat cluster$i.pdb \u003e\u003e UNCLUSTER.pdb\nexec rm cluster$i.pdb\n}\n}\n}\nclose $file1\nclose $file2\nclose $file3\nclose $file4\n#-----------Printing OUTPUT files\nputs \" \\n\\n OUTPUT files :\\n---------------\\n\"\nputs $logfile   \" \\n\\n OUTPUT files :\\n---------------\\n\"\nputs \" \\n CLUSTER-A.pdb\\n CLUSTER-B.pdb\\n CLUSTER-C.pdb \\n UNCLUSTER.pdb \\n cluster.log \\n\"\nputs $logfile \" \\n CLUSTER-A.pdb\\n CLUSTER-B.pdb\\n CLUSTER-C.pdb \\n UNCLUSTER.pdb \\n cluster.log \\n\"\n\n#\nputs \"\\n\\n\\n \\t  \\t $********** ANJI BABU KAPAKAYALA **********$\\n\\n\\n\"\nputs $logfile \"\\n\\n\\n \\t  \\t $********** ANJI BABU KAPAKAYALA **********$\\n\\n\\n\"\nclose $logfile\n}\n#====================================================#\n# TCL VMD Script to measure average strucure from given frames\n#\n# Usage  : avg_str \u003cmolid\u003e \u003catom selection\u003e\n#\n# Example : avg_str 0 \"protein\"\n# Example : avg_str 1 \"backbone\"\n#\n#\nproc avg_str {id sel} {\nset nframes [molinfo $id get numframes]\nputs \" No. of frames : $nframes\"\n#--------------------#\nset sel1 [atomselect $id $sel]\nset avgpos [measure avpos $sel1]\n# Moves the selected atoms to the average positions computed\n $sel1 set {x y z} $avgpos\n# Write into pdb\n$sel1 writepdb Avg-Pos-$id.pdb\nputs \"\\n ********** KAPAKAYALA ANJI BABU **********$ \"\n}\n#------------------------------------------------------#\n#        WRITTEN BY ANJI BABU KAPAKAYALA             #\n#====================================================#\n\n```\n-------------------------------------------------------------------------------------------------\n\n\n\n  $********** ANJI BABU KAPAKAYALA **********$\n\n\nCHEERS ....!!!!!!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanjibabuiitk%2Fcluster-analysis-using-vmd-tcl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanjibabuiitk%2Fcluster-analysis-using-vmd-tcl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanjibabuiitk%2Fcluster-analysis-using-vmd-tcl/lists"}