Skip to content

Instantly share code, notes, and snippets.

View carushi's full-sized avatar

carushi carushi

View GitHub Profile
@carushi
carushi / Error_resolver.R
Last active April 9, 2018 05:56
To resolve an error when running ReactomePA (Error in levels <- ... factor level is duplicated Calls: ... fortify.enrichResult -> fortify.internal -> factor
fc_gene <- enrichPathway(gene=unique(names(fc)), pvalueCutoff=0.1, organism = "mouse", readable=T)
fc_gene
attributes(fc_gene)
index <- sapply(seq(1, length(fc_gene$Description)), function(x){return(which(fc_gene$Description == fc_gene$Description[x])[1] == x)})
attr(fc_gene, "result") <- attr(fc_gene, "result")[index,]
dotplot(fc_gene, showCategory=15)
@carushi
carushi / gist:e079974decf7b6d2900bd570a83199d8
Created April 9, 2018 05:49
To resolve an error message from ReactomePA (Error in levels <- ... factor level is duplicated Calls: ... fortify.enrichResult -> fortify.internal -> factor
fc_gene <- enrichPathway(gene=unique(names(fc)), pvalueCutoff=0.1, organism = "mouse", readable=T)
fc_gene
attributes(fc_gene)
index <- sapply(seq(1, length(fc_gene$Description)), function(x){return(which(fc_gene$Description == fc_gene$Description[x])[1] == x)})
attr(fc_gene, "result") <- attr(fc_gene, "result")[index,]
dotplot(fc_gene, showCategory=15)
@carushi
carushi / list_length.py
Created July 6, 2017 07:56
Recursive list length check. (arrayとかndarrayとかが厳密でないといけないので、もっと上位のクラスに設定するとよいのかな。)
def list_length(L):
if isinstance(L, (list, np.ndarray)):
if len(L) > 0 and isinstance(L[0], (list, np.ndarray)):
return [list_length(x) for x in L]
else:
return len(L)
return 0
@carushi
carushi / softclip_distribution.sh
Last active December 8, 2016 13:11
Bowtieのマルチマップでない15塩基以上のリードに対して5'端側のソフトクリップの塩基数をとりたいとき (0もカウント)
samtools view -f 16 temp.bam \
| awk 'BEGIN{OFS='\t'}{if(NF == 3 || length($10) >= 15) { print }}' \
| cut -f6,6 | sed -e 's/.*[^S]$/0/g' -e 's/.*[A-Z]\([0-9]*\)S$/\1/g' | sort -n \
| uniq -c > temp_rev.txt
samtools view -F 16 temp.bam \
| awk 'BEGIN{OFS='\t'}{if(NF == 3 || length($10) >= 15) { print }}' \
| cut -f6,6 | sed -e 's/^\([0-9]*\)S.*$/\1/g' -e 's/^.*[A-Z]$/0/g' | sort -n \
| uniq -c > temp.txt
@carushi
carushi / softclip_distribution.sh
Last active December 6, 2016 14:24
Bowtieのマルチマップでない15塩基以上のリードに対して5'端側のソフトクリップの塩基数をとりたいとき
seq 0 5 | xargs -I{} echo "samtools view -F 16 {}.bam | grep -v "XS:" | awk 'BEGIN{OFS='\t'}{if(length(\$10) >= 15) { print }}' | cut -f6,6 | grep \"^[0-9]*S\" | cut -f1,1 -d\"S\" | sort -n | uniq -c > {}_local.txt " | bash
seq 0 5 | xargs -I{} echo "samtools view -f 16 {}.bam | grep -v "XS:" | awk 'BEGIN{OFS='\t'}{if(length(\$10) >= 15) { print }}' | cut -f6,6 | grep \"[0-9]*S$\" | sed 's/.*[A-Z]\([0-9]*\)S\$/\1/g' | sort -n | uniq -c > {}_local_rev.txt " | bash
@carushi
carushi / read_truncate.py
Last active September 23, 2021 17:23
For "Error, fewer reads in file specified with -2 than in file specified with -1 terminate called after throwing an instance of 'int' (ERR): bowtie2-align died with signal 6 (ABRT) (core dumped)"
#!/usr/bin/env python
""" Please apply this script to paired-end reads when you happen to see the bowtie error shown as below.
Error, fewer reads in file specified with -2 than in file specified with -1
terminate called after throwing an instance of 'int'
(ERR): bowtie2-align died with signal 6 (ABRT) (core dumped)
python read_truncate.py (1st fastq) (2nd fastq)
"""
@carushi
carushi / check_qs.sh
Created April 6, 2016 08:57
correct the fastq in wrong format
ERRORLIST=("SRRXXXXXX") #SRR number
for NAME in "${ERRORLIST[@]}"
do
echo $NAME
cat ${NAME}.fastq | grep "^@SRR" -A 3 | grep -v "^\-\-$" > ${NAME}_trimmed.fastq
python check_read.py ${NAME}_trimmed.fastq > ${NAME}_extracted.fastq
done
@carushi
carushi / check_read.py
Last active April 6, 2016 09:05
check read and quality score length
import sys
if __name__ == '__main__':
file = sys.argv[1]
list = []
count = 0
with open(file) as f:
for line in f.readlines():
if count%4 == 1:
list.append(line)
for (time in c(10, 100, 1000, 10000, 100000, 100000)) {
m <- c()
for (r in 1:10000) {
m <- c(m, max(rnorm(time)))
}
png(paste(time, ".png", sep=""))
plot(hist(m), xlim=c(-2,6))
dev.off()
}
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.maximize_window()
driver.get("http://ksnctf.sweetduet.info/q/3/unya.html")
# driver.title
form = driver.find_element_by_xpath('//input[@type="text"]')
form.send_keys('c')