Skip to content

Instantly share code, notes, and snippets.

View ShujiaHuang's full-sized avatar
:octocat:
Focusing

Shujia Huang ShujiaHuang

:octocat:
Focusing
View GitHub Profile
@ShujiaHuang
ShujiaHuang / Merge.pl
Last active August 29, 2015 14:03
Common Code In Work
#!/usr/bin/perl
use strict;
use warnings;
#1. 纯区域的Merge
sub Merge {
my ( $dis_delta, @region) = @_; # An array , format: [chrId, start, end]
my ( %prePos, @data, $id, $start, $end );
@ShujiaHuang
ShujiaHuang / Overlap.pl
Created July 22, 2014 21:17
Find the Overlap region between in the two file
# Author : Shujia Huang
# Date : 2013-01-10
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
my ( $posFile, $regionFile );
@ShujiaHuang
ShujiaHuang / InAndOutFa.cpp
Last active August 29, 2015 14:05
读存Fa文件
// C++ read fa-sequence
void ReadFaSeq(const char *file, map<string, string> &fa) {
ifstream I(file);
if (!I){
cerr << "Cannot open file : " << file << endl;
exit(1);
}
string tmp, refId;
@ShujiaHuang
ShujiaHuang / TestPysam.py
Created October 18, 2014 08:37
测试pysam 包的使用
"""
Test pysam
"""
import pysam
import numpy as np
def Test1 () :
samfile = pysam.Samfile('1006-01.bam', 'rb')
@ShujiaHuang
ShujiaHuang / PerlIOgzip.pl
Last active August 29, 2015 14:08
Perl gz 读写
#!/usr/bin/perl
use warnings;
use strict;
use PerlIO::gzip;
die "perl $0 <.gz file in> <.gz file out>" unless @ARGV==2;
#!/bin/bash
# If you adapt this script for your own use, you will need to set these two variables based on your environment.
# SV_DIR is the installation directory for SVToolkit - it must be an exported environment variable.
# SV_TMPDIR is a directory for writing temp files, which may be large if you have a large data set.
#export SV_DIR=`cd .. && pwd`
SV_DIR=/home/siyang/bin/software_pip/svtoolkit
SV_TMPDIR=
runDir=
@ShujiaHuang
ShujiaHuang / uninstall_homebrew.sh
Created December 17, 2015 06:23
如何有效卸载homebrew
#!/bin/sh
# Just copy and paste the lines below (all at once, it won't work line by line!)
# MAKE SURE YOU ARE HAPPY WITH WHAT IT DOES FIRST! THERE IS NO WARRANTY!
# https://gist.github.com/mxcl/1173223
function abort {
echo "$1"
exit 1
}
set -e
@ShujiaHuang
ShujiaHuang / pure_data.pl
Last active February 26, 2016 01:36
用于判定窗口长度,完成窗口定位和窗口内甲基化率计算,常用于甲基化Canonical分析
#Author : Shujia Huang
#Date : 2010/11/27
#!/usr/bin/perl -w
use strict;
use warnings;
my ( $file, $outfile_prefix, @bin_num ) = @ARGV;
my %region2num = ( "1000upstream" => 0, "first-exon" => 1, "intron" => 2,
"mid-exon" => 3, "last-exon" => 4, "1000downstream" => 5 );
### Read Fa sequence ###
sub ReadFaSeq {
my ( $file, $fa ) = @_;
my ( $refId, $seq );
open I, $file or die "Cannot open file : $file\n";
$/ = ">"; <I>; $/ = "\n";
while ( <I> ) {
### Read Fa sequence ###
sub ReadFaSeq {
my ( $file, $fa ) = @_;
my ( $refId, $seq );
open I, $file or die "Cannot open file : $file\n";
$/ = ">"; <I>; $/ = "\n";
while ( <I> ) {