This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
import gzip | |
import pandas as pd | |
import re | |
GTF_HEADER = ['seqname', 'source', 'feature', 'start', 'end', 'score', | |
'strand', 'frame'] | |
R_SEMICOLON = re.compile(r'\s*;\s*') | |
R_COMMA = re.compile(r'\s*,\s*') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
matcher <- function(pattern, x) { | |
ind = gregexpr(pattern, x)[[1]] | |
start = as.numeric(ind) | |
end = start + attr(ind, "match.length")- 2 | |
apply(cbind(start,end), 1, function(y) substr(x, start=y[1], stop=y[2])); | |
} | |
doone <- function(c, cigar) { | |
pat <- paste("\\d+", c , sep="") | |
sum(as.numeric(matcher(pat, cigar)), na.rm=T) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Variable name to character | |
deparse(substitute(variable)) | |
"variable" | |
# Character to variable | |
eval(as.name("variable")) |
NewerOlder