Code:
$ cat dna.awk
old0!=$0 { old0=$0; i=2 }
i<=5 {
while (!($i || $(i+4)) && i<=5)
i++
if (i<=5) {
print $0, ($i>$(i+4) ? "+" : "-")
i++
next
}
}
i==6 && /\.|,/ {
print $0, (split($0, a, /\./) > split($0, a, /,/) ? "+" : "-")
}
$ cat data
.......GGGG,.G,,G...G.,.T...G.,..,.,,^F, 0 0 8 1 0 0 0 0
.......GGGG,.G,,G...G.,.T...G.,..,.,,^F, 0 0 8 1 0 0 0 0
.......GGGG,.G,,G...G.,.T...G.,..,.,,^F, 0 0 8 1 0 0 0 0
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0
ccCCcc$c$cCC$CC$ccccCc$CCCccccCcccccCCCcCCcCccCccCCCCCCCcCcCCcCCCcccCCCCCC 0 37 0 0 0 32 0 0
ggGGgGGgggGGGGggggGgggggGGGgGGgGggGggGGGGGGGgGgGGgGGGgggGGGGGGg 0 0 35 0 0 0 28 0
.....,,..,,...,,......,...cA.c,cC. 1 1 0 0 0 3 0 0
.....,,..,,...,,......,...cA.c,cC. 1 1 0 0 0 3 0 0
.....,,..,,...,,......,...cA.c,cC. 1 1 0 0 0 3 0 0
$ awk -f dna.awk data
.......GGGG,.G,,G...G.,.T...G.,..,.,,^F, 0 0 8 1 0 0 0 0 +
.......GGGG,.G,,G...G.,.T...G.,..,.,,^F, 0 0 8 1 0 0 0 0 +
.......GGGG,.G,,G...G.,.T...G.,..,.,,^F, 0 0 8 1 0 0 0 0 +
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0 -
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0 -
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0 -
,gc,,cga,g,c,,,,,,, 0 0 0 0 1 3 3 0 -
ccCCcc$c$cCC$CC$ccccCc$CCCccccCcccccCCCcCCcCccCccCCCCCCCcCcCCcCCCcccCCCCCC 0 37 0 0 0 32 0 0 +
ggGGgGGgggGGGGggggGgggggGGGgGGgGggGggGGGGGGGgGgGGgGGGgggGGGGGGg 0 0 35 0 0 0 28 0 +
.....,,..,,...,,......,...cA.c,cC. 1 1 0 0 0 3 0 0 +
.....,,..,,...,,......,...cA.c,cC. 1 1 0 0 0 3 0 0 -
.....,,..,,...,,......,...cA.c,cC. 1 1 0 0 0 3 0 0 +