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 / rmSeqFromFastaByPtnFile.sh
Created June 10, 2020 05:27
remove sequences from FASTA in pattern file
#!/usr/bin/bash
awk '{ if ((NR>1)&&($0~/^>/)) { printf("\n%s", $0); } else if (NR==1) { printf("%s", $0); } else { printf("\t%s", $0); } }' \
| grep -vwf $1 - \
| tr "\t" "\n"
awk '{OFS="\t"; print ">"$1"\n"$10}'
python3 -m http.server $1
conda install -c anaconda ipykernel
python -m ipykernel install --user --name=$1
@poeli
poeli / vim
Created March 20, 2020 19:40
DOS format to UNIX
:e ++ff=dos
:set ff=unix
sudo xcode-select -switch /Library/Developer/CommandLineTools/
# USAGE: jq -R -s -f sacct2json.jq
# objectify/1 takes an array of string values as inputs, converts
# numeric values to numbers, and packages the results into an object
# with keys specified by the "headers" array
def objectify(headers):
# For jq 1.4, replace the following line by: def tonumberq: .;
def tonumberq: tonumber? // .;
. as $in
| reduce range(0; headers|length) as $i ({}; .[headers[$i]] = ($in[$i] | tonumberq) );
@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}}'
#!/usr/bin/env perl
$string=$ARGV[0];
$cnt=0;
$found=1;
while(<STDIN>){
if( $cnt%4==0){
if( /$string/i ){
$found=1;
@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}'