Skip to content

Instantly share code, notes, and snippets.

@popucui
Last active September 30, 2018 04:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save popucui/6f3295d5f854f8b8b54eb8d822f54015 to your computer and use it in GitHub Desktop.
Save popucui/6f3295d5f854f8b8b54eb8d822f54015 to your computer and use it in GitHub Desktop.
# print 2 line into one
awk 'NR%2{printf "%s ",$0;next;}1' yourFile
# copy files using rsync
rsync -avz -h --progress --files-from=./fastq_list user@host:/ .
# change password from script
# this is used not often, yet can be very useful when you need to change passwd from VPS provider's dasgboard
`echo "newpasswd" | passwd root --stdin`
# transform head line to a vector
head -1 /path/to/file_with_multiple_columns.tsv | awk 'ORS=", " { for(i=1; i<=NF; i++) {print "\""$i"\""} }'
# add space for string as "2/13", for MS Excel will automatically recognize "2/13" as date format "Feb. 13th"
sed -i -re 's#([[:digit:]]+/[[:digit:]]+)# \1#' variant_summary/vm_gt002.xls
# map Ensembl transcript ID to Refseq ID
mysql -u anonymous -h ensembldb.ensembl.org homo_sapiens_core_75_37 -B -e
"SELECT transcript.stable_id, xref.display_label FROM transcript, object_xref, xref,external_db
WHERE transcript.transcript_id = object_xref.ensembl_id AND object_xref.ensembl_object_type = 'Transcript'
AND object_xref.xref_id = xref.xref_id AND xref.external_db_id = external_db.external_db_id
AND external_db.db_name = 'RefSeq_mRNA';" > ensemble_refseq.txt
# match single quote in sed
sed -i 's#5'\''URS#5_URS#' downloads/variant_summary.txt
# To escape single quote or double quote in PHP when talking to MySQL, check http://php.net/mysqli_real_escape_string
$city = "'s Hertogenbosch";
$city = mysqli_real_escape_string($link, $city);
@popucui
Copy link
Author

popucui commented Aug 22, 2018

# show time in a formated way
date +"%Y-%m-%d %T"

@popucui
Copy link
Author

popucui commented Aug 27, 2018

# convert SAM/BAM to fasta
samtools view -bS L15M_CCDC6.sam | samtools bam2fq - | seqtk seq -A - > tmp/L15_CCDC6_reads.fa

@popucui
Copy link
Author

popucui commented Sep 3, 2018

# split a large file by size, 1G here
split -b 1024m "file.tar.gz" "file.tar.gz.part-"

@popucui
Copy link
Author

popucui commented Sep 25, 2018

# test disk IO speed
dd if=/dev/zero of=/tmp/test1.img bs=1G count=10 oflag=dsync

@popucui
Copy link
Author

popucui commented Sep 29, 2018

# vep use online database
/data/home/jiecui/software/anaconda2/envs/py36/bin/vep --no_progress --cache --force --stats_text --numbers --hgvs --fasta /home/athurvagore/.vep/homo_sapiens/84_GRCh37/Homo_sapiens.GRCh37.75.dna.primary_assembly.fa --af --af_1kg --pubmed --check_existing --protein --symbol --xref_refseq --vcf --allow_non_variant --dir /data/home/jiecui/database/vep/v90_grch37 --assembly GRCh37 --fork 4 -i <input.txt>  --port 3337 -o <output_vep.vcf>

# input.txt could be: 17:g.41246595T>ACA

@popucui
Copy link
Author

popucui commented Sep 30, 2018

# check my IP address
curl https://api.myip.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment