The below code works great if the user inputs a single value. The sed command applies the NM_ with the user input it is saved to a file. However, if two values are entered the below does not work. Can both values be saved at the same time if they are entered in windows format? Thank you :).
gjb2() {
printf "\n\n"
printf "What is the id of the patient getting GJB2 analysis : "; read id
printf "Enter variant(s): "; read variant
[ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && return
[ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && return
# save file in windows python directory
printf "%s\n" "$variant" > c:/Users/cmccabe/Desktop/Python27/$id.txt
# add transcript
sed -i '$a NM_004004.5:' c:/Users/cmccabe/Desktop/Python27/$id.txt
printf "NM_004004.5:%s\n" "$variant" > c:/Users/cmccabe/Desktop/Python27/$id.txt
add2text ${id}.txt
gjb2name
}
user enters: c.74G>A
1 value output
NM_004004.5:c.74G>A
user enters:c.79G>A,c.283G>A
current 2 value output
NM_004004.5:c.74G>A,c.283G>A
Desired 2 value output
NM_004004.5:c.74G>A
NM_004004.5:c.283G>A
You create a file, the transcript is commented out, and then you overwrite the newly created file? Quite misleading for the reader ... I'd propose to get your act together and streamline the script.
The user inputs the variant and the sed command appends the transcript at the end (after the variant) So like this c.79G>ANM_004004.5:
the printf re-orders that to NM_004004.5:c.79G>A and saves that file in the python directory. Probably not the most efficient, but I will take your advice and work on it.
Out of curiosity do you find more scientists, especially genomic specialists, learning to program. Just curious because the data is huge and bioinformatics is becoming more important. Thank you :).
---------- Post updated at 01:57 PM ---------- Previous update was at 01:42 PM ----------
Maybe:
gjb2() {
printf "\n\n"
printf "What is the id of the patient getting GJB2 analysis : "; read id
printf "Enter variant(s): "; read variant
[ -z "$id" ] && printf "\n No ID supplied. Leaving match function." && sleep 2 && return
[ "$id" = "end" ] && printf "\n Leaving match function." && sleep 2 && return
printf "NM_004004.5:%s\n" "$variant" > c:/Users/cmccabe/Desktop/Python27/$id.txt
while true
do
IFS="," read -a TArr <<<"$variant"
echo ${#TArr[@]}
2
echo ${TArr[@]}
$variant
done
add2text ${id}.txt
gjb2name
}