Skip to content

Instantly share code, notes, and snippets.

View soh-i's full-sized avatar

Soh Ishiguro soh-i

View GitHub Profile
@soh-i
soh-i / test.py
Created May 14, 2015 01:43
Simple UnitTest
import unittest
import basic_questions
class TestBasicQuestions(unittest.TestCase):
def setUp(self):
self.gff_dict = basic_questions.read_GFF_file("hsa.gff3")
def test_question1(self):
# Expected value of question1
expected = {"mature": 2711, "primary": 1749}
@soh-i
soh-i / disable_keyboard.sh
Last active August 29, 2015 14:19
disable/enable keyboard events for HHKB
#!/usr/bin/env bash
/Applications/Karabiner.app/Contents/Library/bin/karabiner select_by_name HHKB # to HHKB mode
sudo kextunload /System/Library/Extensions/AppleUSBTopCase.kext/Contents/PlugIns/AppleUSBTCKeyboard.kext
case $? in
3) exit 0;;
*) exit $?;;
esac
@soh-i
soh-i / mimat2mi.py
Last active October 22, 2024 10:05
Convert mirbase mature ID (MIMAT) to pre ID (MI)
import HTSeq
def MIMAT_to_MI(mimat):
# Convert MIMAT (mature) to MI ID (pre) of mirbase.org
mat_gtf = "path_to_mature.gtf"
pre_gtf = "path_to_pre.gtf"
for mgtf in HTSeq.GFF_Reader(mat_gtf):
if mimat == mgtf.attr["transcript_id"]:
pre_query = mgtf.attr["Derives_from"]
return filter(lambda pre: pre.attr["transcript_id"] == pre_query,
@soh-i
soh-i / q.py
Created March 13, 2015 14:13
Query genomic sequence
from pyfasta import Fasta
f = Fasta("db/Human/Homo_sapiens/UCSC/hg19/Sequence/WholeGenomeFasta/genome.fa")
mir_base = "GGCUGAGCCGCAGUAGUUCUUCAGUGGCAAGCUUUAUGUCCUGACCCAGCUAAAGCUGCCAGUUGAAGAACUGUUGCCCUCUGCC".replace("U", "T")
mir_22 = {"chr": "chr17", "start":1617197 , "stop":1617281, "strand": "-"}
seq = f.sequence(mir_22)
if mir_base == seq:
print mir_22
@soh-i
soh-i / 7a5p.csv
Created March 10, 2015 10:10
various hsa-let-7a-5p?
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
chr11,.,exon,122017276,122017297,.,-,.,transcript_id "MIMAT0000062"; Alias "MIMAT0000062"; Name "hsa-let-7a-5p"; Derives_from "MI0000061";
chr22,.,exon,46508632,46508653,.,+,.,transcript_id "MIMAT0000062_1"; Alias "MIMAT0000062"; Name "hsa-let-7a-5p"; Derives_from "MI0000062";
chr9,.,exon,96938244,96938265,.,+,.,transcript_id "MIMAT0000062_2"; Alias "MIMAT0000062"; Name "hsa-let-7a-5p"; Derives_from "MI0000060";
@soh-i
soh-i / w.R
Last active August 29, 2015 14:16
wrap ggplot
plot.wrap <- function(df, x, y, filename, ...) {
g <- ggplot(df, aes_string(x=x, y=y)) +
geom_point(colour="limegreen", size=3) + theme_light() + ...
ggsave(plot=g, filename=filename)
d <- data.frame(A=1:10, B=2:11, C=3:12)
plot.wrap(d, "A", "B", filename="AB.pdf") # A-B plot
plot.wrap(d, "A", "C", filename="AC.pdf") # A-C plot
plot.wrap(d, "B", "C", filename="BC.pdf") # B-C plot
@soh-i
soh-i / Clin.xml
Created February 23, 2015 10:57
ClinVar header
##fileformat=VCFv4.0
##fileDate=20141202
##source=ClinVar and dbSNP
##dbSNP_BUILD_ID=142
##reference=GRCh37.p13
##phasing=partial
##variationPropertyDocumentationUrl=ftp://ftp.ncbi.nlm.nih.gov/snp/specs/dbSNP_BitField_latest.pdf
##INFO=<ID=RS,Number=1,Type=Integer,Description="dbSNP ID (i.e. rs number)">
##INFO=<ID=RSPOS,Number=1,Type=Integer,Description="Chr position reported in dbSNP">
##INFO=<ID=RV,Number=0,Type=Flag,Description="RS orientation is reversed">
@soh-i
soh-i / seq.scala
Created February 20, 2015 14:40
Scala practice
object Main {
def complement(nuc: List[String]): List[String] = {
nuc.map { nt =>
nt match {
case "A" => "T"
case "T" => "A"
case "G" => "C"
case "C" => "G"
case _ => throw new IllegalArgumentException("Invalid seq")
}
@soh-i
soh-i / p.sh
Created January 16, 2015 08:27
Bowtie2 running as pipe
bowtie2 -x genome -p 12 -1 1.fq -2 2.fq | samtools view -bS -@4 - | samtools sort -@4 - bw_map.sorted
@soh-i
soh-i / nt.zsh
Created December 23, 2014 07:15
Notify exit status to Notification Center on Yosemite
pn() {
terminal-notifier -subtitle "Finished job" -message "Status: $?"
}