根据vcf表数据在字符串中更改宪章

我有一个长字符串文件(b'\x04\xea\x9cZ\x84\x0e\xa9\xc5\xa8|\x00@\x04\x11\r\x0b\x0f\x80\x00\x00,\xc0\x00\x00\x00\x00\x00\x00\x80\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')(string.txt) 还有一个vcf表(abcdefghijklmnop),就像这样

file.vcf

该表还包含position 2 4 6 10 n... name1 a b c d name2 x y z a namen... "mis",在这种情况下,不应替换字符

我想更改特定位置的字符并将所有字符串存储在一个新文件中,该文件看起来像这样

"het"

有没有办法在bash循环中做到这一点?

wqs695932489 回答:根据vcf表数据在字符串中更改宪章

请尝试以下操作:

files = File::where('agent_id',$user->id)
     ->with(['posts' => function ($q) {
         $q->select('name','phone'); // specify whatever you want
      }])->get(['column1','column2']);

string.txt:

mapfile -t string < <(fold -w1 "string.txt")
# set string to an array of single characters: ("a" "b" "c" "d" ..)

while read -ra ary; do
    if [[ ${ary[0]} = "position" ]]; then
        # 1st line of file.vcf
        declare -a pos=("${ary[@]:1}")
        # now the array pos holds: (2 4 6 10 ..)
    else
        # 2nd line of file.vcf and after
        declare -a new=("${string[@]}")
        # make a copy of string to modify
        for ((i=0; i<${#pos[@]}; i++ )); do
            repl="${ary[$i+1]}"    # replacement
            if [[ $repl != "mis" && $repl != "het" ]]; then
                new[${pos[$i]}-1]="$repl"
                # modify the position with the replacement
            fi
        done
        echo ">${ary[0]}"
        (IFS=""; echo "${new[*]}")
        # print the modified array as a concatenated string
    fi
done < "file.vcf"

file.vcf:

abcdefghijklmnop

输出:

position 2 4 6 10
name1 a b c d
name2 x y z a
name3 i mis k l

我试图将解释作为注释嵌入到上面的脚本中,但是 如果您还有问题,请随时提问。

希望这会有所帮助。

本文链接:https://www.f2er.com/3048121.html

大家都在问