%%bash
echo "TODAY'S DATE:"
date
echo "------------"
echo ""
#Display operating system info
lsb_release -a
echo ""
echo "------------"
echo "HOSTNAME: "; hostname
echo ""
echo "------------"
echo "Computer Specs:"
echo ""
lscpu
echo ""
echo "------------"
echo ""
echo "Memory Specs"
echo ""
free -mh
TODAY'S DATE: Wed Jan 22 14:30:07 PST 2020 ------------ Distributor ID: Ubuntu Description: Ubuntu 16.04.6 LTS Release: 16.04 Codename: xenial ------------ HOSTNAME: swoose ------------ Computer Specs: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 24 On-line CPU(s) list: 0-23 Thread(s) per core: 2 Core(s) per socket: 6 Socket(s): 2 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 44 Model name: Intel(R) Xeon(R) CPU X5670 @ 2.93GHz Stepping: 2 CPU MHz: 2925.783 BogoMIPS: 5851.61 Virtualization: VT-x L1d cache: 32K L1i cache: 32K L2 cache: 256K L3 cache: 12288K NUMA node0 CPU(s): 0-23 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm epb ssbd ibrs ibpb stibp kaiser tpr_shadow vnmi flexpriority ept vpid dtherm ida arat flush_l1d ------------ Memory Specs total used free shared buff/cache available Mem: 70G 5.4G 410M 547M 65G 64G Swap: 4.7G 777M 3.9G
No LSB modules are available.
# Set data directories
%env crab_data=/home/sam/data/C_bairdi/RNAseq
%env hemat_data=/home/sam/data/Hematodinium/RNAseq
%env wd=/home/sam/analyses
# Programs
%env seqtk=/home/sam/programs/seqtk-1.3/seqtk
env: crab_data=/home/sam/data/C_bairdi/RNAseq env: hemat_data=/home/sam/data/Hematodinium/RNAseq env: wd=/home/sam/analyses env: seqtk=/home/sam/programs/seqtk-1.3/seqtk
FastAs: https://gannet.fish.washington.edu/Atumefaciens/20200114_cbai_MEGAN_read_extractions/
Trimmed-FastQs: https://gannet.fish.washington.edu/Atumefaciens/20191218_cbai_fastp_RNAseq_trimming/
Use FastA IDs from MEGAN6 taxonomic read extraction FastAs to pull out appropriate reads from each phylum (Arthropoda and Alveolata). This is performed because MEGAN6 strips paired read ID after the first space. As such, the resulting read extractions using MEGAN end up with a FastA file containing two reads with identicial headers. Not sure if this will cause any downstream issues (i.e. with Trinity) where paired end data is used, so playing it safe and using the truncated IDs to pull FastQs with complete sequence headers for use in subsequent data wrangling.
%%bash
timestamp=$(date +%Y%m%d)
for directory in ${crab_data} ${hemat_data}
do
# Get species name
species=$(echo ${directory} | awk -F"/" '{print $5}')
# Make new directory and change to that directory ("$_" means use previous command's argument)
mkdir --parents ${wd}/"${timestamp}"."${species}"_megan_reads \
&& cd "$_" || exit
# Set seqtk list filename
seqtk_list=${timestamp}.${species}.seqtk.read_id.list
# Set output FastQ filenames
R1_fq=${timestamp}.${species}.megan_R1.fq
R2_fq=${timestamp}.${species}.megan_R2.fq
######################################################
# Create FastA IDs list to use for sequence extraction
######################################################
for fasta in "${directory}"/*.fasta
do
echo "Pulling FastA IDs from ${fasta}"
echo ""
grep ">" "${fasta}" | awk 'sub(/^>/, "")'
done | sort -u >> "${seqtk_list}"
echo ""
echo "Finished with FastA ID extraction."
echo ""
echo "Moving on to read extractions..."
echo ""
echo ""
######################################################
# Extract corresponding R1 and R2 reads using seqtk FastA ID list
######################################################
for fastq in "${directory}"/*R1*.gz
do
echo "Extracting R1 reads from ${fastq}"
echo ""
${seqtk} subseq "${fastq}" "${seqtk_list}" >> "${R1_fq}"
done
echo ""
echo "Done with R1 read extractions"
echo ""
echo "------------"
echo ""
echo "Extracting R2 reads from ${fastq}"
for fastq in "${directory}"/*R2*.gz
do
echo "Extracting R2 reads from ${fastq}"
echo ""
${seqtk} subseq "${fastq}" "${seqtk_list}" >> "${R2_fq}"
done
echo "-------------------------------------"
# Print working directoyr and list files
pwd
ls -ltrh
echo ""
echo "-------------------------------------"
echo ""
done
Finished with FastA ID extraction. Moving on to read extractions... Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/304428_S1_L001_R1_001.fastp-trim.201912183855.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/304428_S1_L002_R1_001.fastp-trim.201912184416.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329774_S1_L001_R1_001.fastp-trim.201912184855.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329774_S1_L002_R1_001.fastp-trim.201912185239.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329775_S2_L001_R1_001.fastp-trim.201912185554.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329775_S2_L002_R1_001.fastp-trim.201912185856.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329776_S3_L001_R1_001.fastp-trim.201912180142.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329776_S3_L002_R1_001.fastp-trim.201912180540.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329777_S4_L001_R1_001.fastp-trim.201912180900.fq.gz Extracting R1 reads from /home/sam/data/C_bairdi/RNAseq/329777_S4_L002_R1_001.fastp-trim.201912181245.fq.gz Done with R1 read extractions ------------ Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329777_S4_L002_R1_001.fastp-trim.201912181245.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/304428_S1_L001_R2_001.fastp-trim.201912183855.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/304428_S1_L002_R2_001.fastp-trim.201912184416.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329774_S1_L001_R2_001.fastp-trim.201912184855.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329774_S1_L002_R2_001.fastp-trim.201912185239.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329775_S2_L001_R2_001.fastp-trim.201912185554.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329775_S2_L002_R2_001.fastp-trim.201912185856.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329776_S3_L001_R2_001.fastp-trim.201912180142.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329776_S3_L002_R2_001.fastp-trim.201912180540.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329777_S4_L001_R2_001.fastp-trim.201912180900.fq.gz Extracting R2 reads from /home/sam/data/C_bairdi/RNAseq/329777_S4_L002_R2_001.fastp-trim.201912181245.fq.gz ------------------------------------- /home/sam/analyses/20200122.C_bairdi_megan_reads total 19G -rw-rw-r-- 1 sam sam 1.3G Jan 22 12:50 20200122.C_bairdi.seqtk.read_id.list -rw-rw-r-- 1 sam sam 8.9G Jan 22 13:10 20200122.C_bairdi.megan_R1.fq -rw-rw-r-- 1 sam sam 8.9G Jan 22 13:29 20200122.C_bairdi.megan_R2.fq ------------------------------------- Finished with FastA ID extraction. Moving on to read extractions... Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/304428_S1_L001_R1_001.fastp-trim.201912183855.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/304428_S1_L002_R1_001.fastp-trim.201912184416.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329774_S1_L001_R1_001.fastp-trim.201912184855.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329774_S1_L002_R1_001.fastp-trim.201912185239.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329775_S2_L001_R1_001.fastp-trim.201912185554.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329775_S2_L002_R1_001.fastp-trim.201912185856.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329776_S3_L001_R1_001.fastp-trim.201912180142.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329776_S3_L002_R1_001.fastp-trim.201912180540.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329777_S4_L001_R1_001.fastp-trim.201912180900.fq.gz Extracting R1 reads from /home/sam/data/Hematodinium/RNAseq/329777_S4_L002_R1_001.fastp-trim.201912181245.fq.gz Done with R1 read extractions ------------ Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329777_S4_L002_R1_001.fastp-trim.201912181245.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/304428_S1_L001_R2_001.fastp-trim.201912183855.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/304428_S1_L002_R2_001.fastp-trim.201912184416.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329774_S1_L001_R2_001.fastp-trim.201912184855.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329774_S1_L002_R2_001.fastp-trim.201912185239.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329775_S2_L001_R2_001.fastp-trim.201912185554.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329775_S2_L002_R2_001.fastp-trim.201912185856.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329776_S3_L001_R2_001.fastp-trim.201912180142.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329776_S3_L002_R2_001.fastp-trim.201912180540.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329777_S4_L001_R2_001.fastp-trim.201912180900.fq.gz Extracting R2 reads from /home/sam/data/Hematodinium/RNAseq/329777_S4_L002_R2_001.fastp-trim.201912181245.fq.gz ------------------------------------- /home/sam/analyses/20200122.Hematodinium_megan_reads total 947M -rw-rw-r-- 1 sam sam 64M Jan 22 13:29 20200122.Hematodinium.seqtk.read_id.list -rw-rw-r-- 1 sam sam 442M Jan 22 13:36 20200122.Hematodinium.megan_R1.fq -rw-rw-r-- 1 sam sam 442M Jan 22 13:44 20200122.Hematodinium.megan_R2.fq -------------------------------------
%%bash
for directory in /home/sam/analyses/20200121.C_bairdi_megan_reads /home/sam/analyses/20200121.Hematodinium_megan_reads
do
cd "${directory}" || exit
for file in *
do
wc -l ${file}
done
done
191512684 20200121.C_bairdi.megan_R1.fq 191512684 20200121.C_bairdi.megan_R2.fq 47878171 20200121.C_bairdi.seqtk.read_id.list 8232564 20200121.Hematodinium.megan_R1.fq 8232564 20200121.Hematodinium.megan_R2.fq 2058141 20200121.Hematodinium.seqtk.read_id.list