fastq-dump --defline-seq '@$sn[_$rn]/$ri' --split-files <SRR ID>, <SRR ID> ...
# Get reads from SRA

Trinity --seqType fq --max_memory 100G --left <file>_1.fastq --right <file>_2.fastq --CPU 8
# Assembly with Trinity -- results in output file Trinity.fasta

bwa index <reference.fa>
# Index with BWA -- reference.fa should be Trinity.fasta

samtools faidx <reference.fa>
# Index with samtools

java -jar $PICARD CreateSequenceDictionary R=<reference.fasta> O=<reference.dict>
# Sequence dictionary with Picard

bwa mem <reference.fasta> <file>_1.fastq <file>_2.fastq > <output.sam>
# Map with BWA

java -jar $PICARD ReplaceSamHeader I=<input.sam> HEADER=<reference.dict> O=<output.sam>
# Add header to SAM (if missing)

samtools view -b <input.sam> > <output.bam>
# Convert to BAM

samtools mpileup -d 999999999 -f <reference.fa> -Q 0 -s -B -x -o <output.pileup> <input.bam>
# Convert BAM to mpileup with mapping quality

samtools merge <output.bam> <input1.bam> <input2.bam> ...
# Merge BAM files if necessary
 
samtools sort <input.bam> -o <output-sorted.bam>
# Sort BAM

time -p angsd -GL 2 -i <sorted.bam> -ref <reference.fasta> -minQ 0 -doGlf 4 -out <output-prefix>
# Calculate GLs with ANGSD

time -p python referee.py -gl <angsd-genotype-likelihood-file.gz> -ref <reference.fa> --fastq --correct -o <output-prefix>
# Calculate reference quality scores with Referee

Rscript /N/u/grthomas/Carbonate/bin/referee/helper-scripts/score_hist.r <referee-output.txt> <plot-output-dir> <pileup-file>
# Plot some stats

grep ">" file.fasta | wc -l
# Count number of scaffolds/transcripts in FASTA file

grep -v ">" file.fasta | wc | awk '{print $3-$1}' 
# Count number of bases in FASTA file

grep "\-1" <referee-output.txt> | wc -l
# Find sites where reference base is N in the referee output

grep "\-2" <referee-output.txt> | wc -l
# Find sites with no reads mapped to them in the referee output

grep -P "\t-1\n" <referee-output.txt> | wc -l
# Find sites where reference l_mismatch = 0 in the referee output when --correct is NOT specified

grep -P "\t-1\t" <referee-output.txt> | wc -l
# Find sites where reference l_mismatch = 0 in the referee output when --correct is specified


