0

I have a R script that takes in a string and compares it with other strings. And then I will submit a bash script to use the R script. But there are about 3000 strings that I want to take in. I don't want to manually submit each job. How can I automate the job submission? Basically my question is how can I submit multiple jobs that uses the same bash script?

I want to take in the first line of each file and use that string to do the comparison.

My R script looks similar to this:

sfile <- commandArgs(trailingOnly = TRUE)
print(sfile == another_string)

My bash script looks like this:

#!/bin/bash
#SBATCH -J BV1
#SBATCH --account=def-*****
#SBATCH --cpus-per-task=1
#SBATCH --mem=4G # 4GiB of memery
#SBATCH -t 0-10:00 # Running time of 10 hr

module load r

Rscript --vanilla $HOME/projects/def-*****/h*****/****/mappabilityprofile/mappabilityprofile.R $1 > $HOME/projects/def-*****/h*****/****/Rout/testRunOutput.$1.Rout 2>&1

The codes that I tried to use to submit the automated jobs to the server in command line is this:

for ii in /path/to/files; do
> line=$(head -n 1 $f)
> sbatch mappabilityprofile.sh line
> done

This doesn't really work because it only submits one job when I want it to submit multiple jobs according to each file.

Is there any way that I could achieve what I want it to do?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
msening
  • 53
  • 6

1 Answers1

1

I found out that I can use

while read first; do read second; sbatch mappabilityprofile.sh "$second"; done

thanks to this post!

msening
  • 53
  • 6