Skip to content

Instantly share code, notes, and snippets.

@alexpreynolds
Created May 17, 2018 22:34
Show Gist options
  • Save alexpreynolds/72c8deb54e85e4028698563d8c49f470 to your computer and use it in GitHub Desktop.
Save alexpreynolds/72c8deb54e85e4028698563d8c49f470 to your computer and use it in GitHub Desktop.
Convert exon-intron list to junction list
BEGIN {
FS="\t";
old_chr = "chrN";
old_start = -1;
old_stop = -1;
old_id = "*";
old_score = "*";
old_strand = "*";
}
{
new_chr = $1;
new_start = $2;
new_stop = $3;
new_id = $4;
new_score = $5;
new_strand = $6;
if (old_id != new_id) {
# new element
old_id = new_id;
}
else {
# construct and print junction
old_score = 2;
print old_chr"\t"old_stop"\t"(old_stop+1)"\t"old_id"\t"old_score"\t"old_strand;
}
old_chr = new_chr;
old_start = new_start;
old_stop = new_stop;
old_id = new_id;
old_score = new_score;
old_strand = new_strand;
}
END {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment