Entering edit mode
3.1 years ago
82101202089
▴
10
first I have a file which have some gene_IDs: ZM011,ZD012,ZF033,..... Then I want to convert these gene id to different numbers. Like ZM011 -> 1, ZD012 -> 2,.... I try use shell script like this:
i=1
cat ids.txt | while read id; do arr[$id]=$i let i++; done
echo ${#arr[@]}
but the output is 0
I don't know how to do this
cat -n ids.txt
should do it? See below for more options:Thank you very much!
But, actually, I need to form a correspondence between the gene ID and the number for subsequent interconversion.
For example, I would save the generated numbers in a file to reduce the size of the file, and then pull out one and convert it back to the corresponding ID when needed
That's why I want to save it as an array
save the output of
cat -n
in a sorted file. At the end usejoin
.