7  Week 3 Exercises

7.1 In-class

  1. Try it out:
./scripts/week3/batch_on_rhino.sh
  1. Try it out:
#| eval: false
sbatch sbatch_test.sh

and examine the following output files:

  1. Try it out:

7.2 Homework exercises

Exercises 1, 2, 3 are required for the badge.

  1. In the data/ folder, there is a list of .csv files. Modify the code below to process each file.
#!/bin/bash
for file in ------
do
  head ------
done
  1. Modify the code in 1) to write a for loop in a script to count the number of lines for each .csv file. The output should be:
echo "${file}\t(wc -l $file)\n"

Run the script and redirect your output to files_out.txt. Put your bash command you used below:

  1. Modify the below script to process the .sam files in ./data/. Save it as sbatch_sam.sh and run it. How many files were generated?
#!/bin/bash
#SBATCH --array=1-________  
module load SAMtools
file_array=(./data/*.sam) 
ind=$((SLURM_ARRAY_TASK_ID-1)) 
current_file=${file_array[$ind]} 
samtools view -c $current_file > ${current_file}.counts.out