Skip to content

Instantly share code, notes, and snippets.

View poeli's full-sized avatar

Po-E Li poeli

  • Los Alamos National Laboratory
View GitHub Profile
@poeli
poeli / socket5_proxy.sh
Last active April 2, 2018 19:10
quick socket5 proxy
# quick socket5 proxy
# set socket5 proxy to $SERVER:$PORT at the browser
ssh -D $PORT -f -C -q -N $SERVER
@poeli
poeli / split_multi_fasta.sh
Last active April 3, 2018 22:03
Split a multi-fasta file to single-fasta named on the basis of sequence name
#USAGE: split_multi_fasta.sh *.fasta
cat $1 | awk -F'>' '/^>/ {match($2,/^(\S+)/,a); FN=a[1]".fa"; print > FN;next;} {print >> FN; close(FN)}'
@poeli
poeli / volume_backup.sh
Last active April 4, 2018 16:04
Backup a single volume from a container to a tar archive
#!/bin/bash
# Backup a single volume from a Docker container to a tar archive.
CONTAINER_NAME=$1
VOLUME_NAME=$2
BACKUPTAR=$3
usage() {
echo "Usage: $0 [container name] [volume name] ([backup.tar])"
exit 1
@poeli
poeli / volume_restore.sh
Last active April 4, 2018 16:04
Restore a single volume from a tar archive to a container
#!/bin/bash
# Restore a single volume from a tar archive to a Docker container
NEW_CONTAINER_NAME=$1
BACKUPTAR=$2
usage() {
echo "Usage: $0 [container name] ([backup.tar])"
exit 1
}
@poeli
poeli / exfat.sh
Created April 5, 2018 21:00
exFAT support on CentOS 7
# ExFAT support on CentOS7
yum install -y http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm
yum install exfat-utils fuse-exfat
# mount disk
# $sudo fdisk -l
# $sudo mount /dev/sda1 /media/
@poeli
poeli / install_docker.sh
Created April 5, 2018 21:26
Install and Use Docker on CentOS 7
# Install and Docker on CentOS 7
# Reference:
# https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-centos-7
sudo yum check-update
# It will add the official Docker repository, download the latest version of Docker, and install it:
curl -fsSL https://get.docker.com/ | sh
# start the Docker daemon
sudo systemctl start docker
@poeli
poeli / extract_read_name_from_fastq.sh
Created May 9, 2018 16:03
Extract read name from FASTQ file
#!/bin/sh
awk 'NR%4==1 {print substr($1,2)}'
@poeli
poeli / fasta_u2t.sh
Created May 9, 2018 19:43
Convert Us to Ts in FASTA file
#!/bin/sh
awk '$0~/^>/{print $0;next}; {gsub("U","T");print $0}'
#!/usr/bin/env perl
$string=$ARGV[0];
$cnt=0;
$found=1;
while(<STDIN>){
if( $cnt%4==0){
if( /$string/i ){
$found=1;
@poeli
poeli / multifasta_to_singlefasta.sh
Last active February 20, 2020 00:14
Split multiFASTA to singleFASTA and use seq id as filenames
awk -F ' ' '{ if(/^>/){F=sprintf("%s.fasta", substr($1,2)); print > F;next;} else {print >> F}}'