Skip to content

Instantly share code, notes, and snippets.

View azmigueldario's full-sized avatar

Miguel D Prieto G azmigueldario

  • Simon Fraser University, CIDGOH
  • Vancouver, Canada
View GitHub Profile
@azmigueldario
azmigueldario / create_input_sheet.sh
Last active August 2, 2023 05:05
Use bash to create a csv file as samplesheet for nextflow
# add headers
echo "sample,read1,read2" > input_samplesheet.csv
for read1 in $(ls path/to/directories{1,2,3}/fastq/*_1.{fastq.gz,fq,fq.gz});
do
# get the basename of file and remove suffix
sample_id=$(echo $read1 | xargs -n 1 basename -s '_1.fastq.gz')
# replace string '_1' for '_2'
read2="${read1/_1/_2}"
# write in a new line for each sample
@azmigueldario
azmigueldario / split_csv_header.sh
Created July 18, 2023 18:01
Split CSV file according to number of lines and keep header
LINES=100
INPUT_FILE='PATH/TO/TEXT/CSV'
tail -n +2 $INPUT_FILE | split -l $LINES - prefix_
for file in prefix_*
do
head -n 1 $INPUT_FILE > tmp_file
cat $file >> tmp_file
mv -f tmp_file $file