shell中实现DNA序列一致性计算

发布时间 2023-09-06 18:06:25作者: 小鲨鱼2018

 

001、

[root@pc1 test02]# ls
a.txt  test.sh
[root@pc1 test02]# cat a.txt            ## 测试数据
ATCCAGCT
GGGCAACT
ATGGATCT
AAGCAACC
TTGGAACT
ATGCCATT
ATGGCACT
[root@pc1 test02]# cat test.sh          ## 测试脚本
#!/bin/bash

for i in $(seq $(awk 'NR == 1{print length}' a.txt))
do
        cut -c $i a.txt | awk  '{ay[$1]++} END {max = 0; for (i in ay) {if(ay[i] > max){max = ay[i]; a = i}}; printf("%s", a)}'
done
printf "\n"
[root@pc1 test02]# bash test.sh         ## 计算结果
ATGCAACT