{"id":785,"date":"2020-11-12T02:17:34","date_gmt":"2020-11-12T10:17:34","guid":{"rendered":"http:\/\/gantovnik.com\/bio-tips\/?p=785"},"modified":"2020-11-12T02:17:34","modified_gmt":"2020-11-12T10:17:34","slug":"136-files-in-tcl","status":"publish","type":"post","link":"https:\/\/gantovnik.com\/bio-tips\/2020\/11\/136-files-in-tcl\/","title":{"rendered":"#136 Files in tcl"},"content":{"rendered":"<p>#136 Files in tcl<\/p>\n<p>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.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nset filename {C:\\My_files\\readme.txt};\r\nC:\\My_files\\readme.txt\r\n\r\nfile join &#x5B;file nativename $filename];\r\nC:\/My_files\/readme.txt\r\n<\/pre>\n<p>While not recommended, it is also possible to escape the \\ character for Windows pathnames by using another \\ preceding each pathname part.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nset filename &quot;C:\\\\My_files\\\\readme.txt&quot;;\r\nC:\\My_files\\readme.txt\r\n\r\nfile join &#x5B;file nativename $filename];\r\nC:\/My_files\/readme.txt\r\n<\/pre>\n<p>If the file readme.txt exists in C:\/My_files, the file exists command will return a value of 1.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfile exists &quot;C:\/My_files\/readme.txt&quot;;\r\n1\r\n<\/pre>\n<p>A file can be opened for reading.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nset fileID &#x5B;file open &quot;C:\/My_files\/readme.txt&quot; r];\r\nputs &quot;$fileID&quot;;\r\nTcl returns the selected fileID.\r\n<\/pre>\n<p>A file can be opened for reading and writing, truncating the file or creating it if it does not exist.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nset fileID &#x5B;file open &quot;C:\/My_files\/readme.txt&quot; w+];\r\nputs &quot;$fileID&quot;;\r\nTcl returns the selected fileID.\r\n<\/pre>\n<p>A file can be opened for reading and writing, appending data to the end of the file.<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nset fileID &#x5B;file open &quot;C:\/My_files\/readme.txt&quot; a+];\r\nputs &quot;$fileID&quot;;\r\nTcl returns the selected fileID.\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>#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. set filename {C:\\My_files\\readme.txt}; C:\\My_files\\readme.txt file join &#x5B;file nativename $filename]; C:\/My_files\/readme.txt While not recommended, it is also possible to escape the \\ character [&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":[24,27],"tags":[],"class_list":["post-785","post","type-post","status-publish","format-standard","hentry","category-hypermesh","category-tcl"],"modified_by":"gantovnik","jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8bH0k-cF","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":551,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/05\/write-variable-to-file-in-tcl\/","url_meta":{"origin":785,"position":0},"title":"Write variable to file in tcl","author":"gantovnik","date":"2020-05-26","format":false,"excerpt":"Write variable to file in tcl [code language=\"python\"] # create some data set data \"This is some test data.\\n\" # pick a filename - if you don't include a path, # it will be saved in the current directory set filename \"test.txt\" # open the filename for writing set fileId\u2026","rel":"","context":"In &quot;tcl&quot;","block_context":{"text":"tcl","link":"https:\/\/gantovnik.com\/bio-tips\/category\/tcl\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9440,"url":"https:\/\/gantovnik.com\/bio-tips\/2025\/04\/459-python-script-to-group-consecutive-numbers-into-ranges-like-in-msc-patran\/","url_meta":{"origin":785,"position":1},"title":"#459 Python Script to Group Consecutive Numbers into Ranges Like in MSC Patran","author":"gantovnik","date":"2025-04-20","format":false,"excerpt":"This Python script reads a text file containing a list of numbers (such as node or element IDs), sorts them, removes duplicates, and groups consecutive numbers into compact ranges - just like MSC Patran's range format. It's a handy tool for preprocessing or organizing large ID lists efficiently. def read_numbers(filename):\u2026","rel":"","context":"In &quot;patran&quot;","block_context":{"text":"patran","link":"https:\/\/gantovnik.com\/bio-tips\/category\/patran\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":579,"url":"https:\/\/gantovnik.com\/bio-tips\/2020\/06\/84\/","url_meta":{"origin":785,"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":2219,"url":"https:\/\/gantovnik.com\/bio-tips\/2024\/06\/431-hypermesh-python-script-to-create-nodes-using-coordinates-from-csv-file\/","url_meta":{"origin":785,"position":3},"title":"#431 HyperMesh python script to create nodes using coordinates from csv file","author":"gantovnik","date":"2024-06-24","format":false,"excerpt":"Finally, I read how to write a script for HyperMesh in python. In this example, the script reads the coordinates of points from a cvs file. [code language=\"python\"] import os import hm import hm.entities as e from hwx import gui import csv model=hm.Model() os.chdir(r\"D:\\projects\\wordpress\\ex431\") with open('ex431_coordinates.csv', mode ='r') as file:\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\/2024\/06\/ex431.png?resize=350%2C200&ssl=1","width":350,"height":200},"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":785,"position":4},"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":951,"url":"https:\/\/gantovnik.com\/bio-tips\/2021\/09\/172-get-book-meta-from-isbn-in-python\/","url_meta":{"origin":785,"position":5},"title":"#172 Get book info from ISBN","author":"gantovnik","date":"2021-09-05","format":false,"excerpt":"#172 Get book info from ISBN [code language=\"python\"] import sys from isbntools.app import * meta_dict=meta(\"156032712X\") title=meta_dict[\"Title\"] title=title.replace(\" \",\".\") author=meta_dict[\"Authors\"][0] author=author.replace(\" \",\".\") year=meta_dict[\"Year\"] isbn=meta_dict[\"ISBN-13\"] filename = title + \".\" + author + \".\" + year + \".\" + isbn + \".pdf\" print(filename) } [\/code]","rel":"","context":"In &quot;python&quot;","block_context":{"text":"python","link":"https:\/\/gantovnik.com\/bio-tips\/category\/python\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/785","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=785"}],"version-history":[{"count":0,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/posts\/785\/revisions"}],"wp:attachment":[{"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/media?parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/categories?post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gantovnik.com\/bio-tips\/wp-json\/wp\/v2\/tags?post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}