{"id":551,"date":"2020-05-26T15:49:24","date_gmt":"2020-05-26T22:49:24","guid":{"rendered":"https:\/\/gantovnik.com\/bio-tips\/?p=551"},"modified":"2020-05-26T15:51:47","modified_gmt":"2020-05-26T22:51:47","slug":"write-variable-to-file-in-tcl","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2020\/05\/write-variable-to-file-in-tcl\/","title":{"rendered":"Write variable to file in tcl"},"content":{"rendered":"<p>Write variable to file in tcl<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# create some data\nset data &quot;This is some test data.\\n&quot;\n# pick a filename - if you don't include a path,\n#  it will be saved in the current directory\nset filename &quot;test.txt&quot;\n# open the filename for writing\nset fileId &#x5B;open $filename &quot;w&quot;]\n# send the data to the file -\n#  omitting '-nonewline' will result in an extra newline\n# at the end of the file\nputs -nonewline $fileId $data\n# close the file, ensuring the data is written out before you continue\n#  with processing.\nclose $fileId\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Write variable to file in tcl # create some data set data &quot;This is some test data.\\n&quot; # pick a filename &#8211; if you don&#8217;t include a path, # it will be saved in the current directory set filename &quot;test.txt&quot; # open the filename for writing set fileId &#x5B;open $filename &quot;w&quot;] # send the data [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_et_pb_use_builder":"","_et_pb_old_content":"","_et_gb_content_width":"","_lmt_disableupdate":"yes","_lmt_disable":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[27],"tags":[],"class_list":["post-551","post","type-post","status-publish","format-standard","hentry","category-tcl"],"modified_by":null,"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-8T","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":785,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/136-files-in-tcl\/","url_meta":{"origin":551,"position":0},"title":"#136 Files in tcl","author":"gantovnik","date":"2020-11-12","format":false,"excerpt":"#136 Files in tcl It is possible to convert a filename to the Tcl format. Notice the curly braces around the filename so that the \\ character isn\u2019t interpreted as the escape character. [code language=\"python\"] set filename {C:\\My_files\\readme.txt}; C:\\My_files\\readme.txt file join [file nativename $filename]; C:\/My_files\/readme.txt [\/code] While not recommended, it\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":907,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/05\/164-batch-script-to-create-md5-hash-for-every-file-in-the-folder-then-write-them-to-the-text-file\/","url_meta":{"origin":551,"position":1},"title":"#164 Batch script to create md5 hash for every file in the folder, then write them to the text file","author":"gantovnik","date":"2021-05-05","format":false,"excerpt":"#164 Batch script to create md5 hash for every file in the folder, then write them in text file [code language=\"python\"] @echo off FOR \/F \"delims=\" %%F IN ('dir \/B \/A \/S *') DO ( for %%D in (\"%%~dpF\\.\") do ( set filename=%%~nxD.md5 ) ) TYPE NUL > %filename% For\u2026","rel":"","context":"In &quot;batch&quot;","block_context":{"text":"batch","link":"https:\/\/gantovnik.com\/bio-tips\/category\/batch\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":579,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/06\/84\/","url_meta":{"origin":551,"position":2},"title":"#84 Volcano plot for gene expression using R","author":"gantovnik","date":"2020-06-15","format":false,"excerpt":"[code language=\"python\"] library(\"readxl\") library(\"ggplot2\") #Best plots library(\"ggrepel\") #Avoid overlapping labels library(\"dplyr\") #set working directory where all files are located getwd() setwd(\"D:\\\\projects\\\\ex89\") getwd() df <- read_excel(\"data.xlsx\") i=3 k_array = c(2,4,6) label_array = c(\"DC\",\"SC\",\"PC\") k <- k_array[i] label <- label_array[i] df = df[c(1,k,k+1)] colnames(df) <- c(\"gene\",\"log_fc\",\"pvalue\") df <- df[- grep(\"NA\", df$gene),] #\u2026","rel":"","context":"In &quot;bioinformatics&quot;","block_context":{"text":"bioinformatics","link":"https:\/\/gantovnik.com\/bio-tips\/category\/bioinformatics\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2020\/06\/Volcanoplot_DC.jpeg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2020\/06\/Volcanoplot_DC.jpeg?resize=350%2C200 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2020\/06\/Volcanoplot_DC.jpeg?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2020\/06\/Volcanoplot_DC.jpeg?resize=700%2C400 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2020\/06\/Volcanoplot_DC.jpeg?resize=1050%2C600 3x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2020\/06\/Volcanoplot_DC.jpeg?resize=1400%2C800 4x"},"classes":[]},{"id":6260,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/11\/452-save-selected-nodes-coordinates-to-csv-file-in-tcl-for-hypermesh\/","url_meta":{"origin":551,"position":3},"title":"#452 Save selected nodes coordinates to*.csv file in tcl for HyperMesh","author":"gantovnik","date":"2024-11-26","format":false,"excerpt":"set script_path [ file dirname [ file normalize [ info script ] ] ] puts $script_path set output_file [file join $script_path \"nodes.csv\"] set file_id [open $output_file \"w\"] puts $file_id \"node_id,x,y,z\" *clearmark nodes 1 *createmarkpanel nodes 1 \"Select Nodes\" set selected_nodes [hm_getmark nodes 1] if {[llength $selected_nodes] == 0} { puts\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8057,"url":"https:\/\/gantovnik.com\/bio-tips\/2025\/02\/458-hypermesh-tcl-script-to-save-selected-node-ids-and-coordinates-to-a-csv-file\/","url_meta":{"origin":551,"position":4},"title":"#458 HyperMesh tcl script to save selected node IDs and coordinates to a csv file","author":"gantovnik","date":"2025-02-20","format":false,"excerpt":"In this example, we create n=40 random nodes, select several of them, and save their node IDs and coordinates in a csv file. proc RandomReal {min max} { return [expr (rand()*($max-$min)+$min)] } set x_min 0.0 set x_max 20.0 set y_min 0.0 set y_max 10.0 set n 40 for {set i\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/gantovnik.com\/bio-tips\/wp-content\/uploads\/2025\/02\/2025-02-20_005944.png?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":2032,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/01\/403-get-nodes-for-all-elements-in-the-fem-model-in-hypermesh-using-tcl-script\/","url_meta":{"origin":551,"position":5},"title":"#403 Get nodes for all elements in the FEM model in HyperMesh using tcl script","author":"gantovnik","date":"2024-01-13","format":false,"excerpt":"ex403.tcl [code language=\"python\"] set script_path [ file dirname [ file normalize [ info script ] ] ] puts $script_path cd $script_path pwd *createmark elems 1 all set elemList [ hm_getmark elements 1 ] *clearmark elements 1 set outfile [open \"ex403.txt\" w] foreach elem_id $elemList { # Get the list of\u2026","rel":"","context":"In &quot;HyperMesh&quot;","block_context":{"text":"HyperMesh","link":"https:\/\/gantovnik.com\/bio-tips\/category\/hypermesh\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/comments?post=551"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/551\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}