GraphAligner
GraphAligner copied to clipboard
Convert alignments to GFA Path lines
Hi Mikko,
Do you have a method to convert the graph alignment for a single read into a GFA Path line? I want to visualise individual read alignments in Bandage.
Hi, I think this should work if you have just one alignment per read:
cut -f 1,6 < alignments.gaf | awk '{print "P\t" $1 "\t" $2 "\t" "*";}' | sed 's/>\([^<>\t ]\+\)/>\1+,/g' | sed 's/<\([^<>\t ]\+\)/<\1-,/g' | tr -d '<>' | sed 's/,\t/\t/g' > alignment-paths.gfa
Or this if you have multiple alignments per read, this will append the location of the aligned part into the read name:
cut -f 1,3,4,6 < alignments.gaf | awk '{print "P\t" $1 "_" $2 "_" $3 "\t" $4 "\t" "*";}' | sed 's/>\([^<>\t ]\+\)/>\1+,/g' | sed 's/<\([^<>\t ]\+\)/<\1-,/g' | tr -d '<>' | sed 's/,\t/\t/g' > alignment-paths.gfa
Thanks for that, not sure why but that command wasn't working on my GAF files.
I've written a a little tool to do the job gaf2path. It should work so long as the path field only ever has >/< followed by the contig name.