I have a TAB file something like this:
VI 280 6 - VRSSAI NV 2739 7 - SAVNATA AR 203 5 - AEERR QA 2517 7 - AQSTPSP SS 1012 5 - GGGSS LA 281 11 - AAEPALSAGSL
And I would like to check the last column for the order of letters in the 1st and 2nd columns. If the matches between the first and last letter in the last column compared to the 1st and 2nd columns, respectively, remain identical. On the contrary, if there are no matches, I would like to find the reverse order in the last column, and then print the line from the letter in the 1st column to the end, and then take the first letter and print it in the letter in the second column. Desired Result:
VI 280 6 - VRSSAI NV 2739 7 - NATASAV AR 203 5 - AEERR QA 2517 7 - QSTPSPA SS 1012 5 - SGGGS LA 281 11 - LSAGSLAAEPA
Thus, I am trying to execute different scripts, but it is not working correctly. I donβt know exactly why.
awk 'BEGIN {FS=OFS="\t"}{gsub(/$2$1/,"\t",$6); print $1$7$6$2}' "input" > "output";
Another way:
awk 'BEGIN {FS=OFS="\t"} {len=split($11,arrseq,"$7$6"); for(i=0;i<len;i++){printf "%s ",arrseq[i],arrseq[i+1]}' `"input" > "output";`
And I am also trying to use the substr function, but finally no one is working correctly. Is it possible to do in bash? thanks in advance
I am trying to give an example to better understand the issue.
$1 $2 $6 LA AAEPALSAGSL (reverse pattern 'AL' $2$1)
desired result in $ 6 from the corresponding letter $ 2 in the reverse pattern to the end following the first letter to the corresponding letter $ 1 in the reverse pattern
$1 $2 $6 LA LSAGSLAAEPA