Myke
Myke

Reputation: 63

How to Loop on a file.txt containing a list of names?

I am using MacOS.

I am trying to annotate Transcription factors Motifs through the fimo tool. I need to run fimo on multiple Motifs --motif $line names contained in the file MotifsList.txt. In order to work, fimo need to access at 2 other files (file.meme, file.fa) beside the MotifsList.txt one. I would run everything from the command line using a produced file.sh containing the script. All the files needed; .txt, .sh, .meme and .fa are stored in the same folder called Motifs_analysis. I would like the out-put Resultfile to be saved in the same cd.

  1. Rows in the MotifsList.txt file :
MOTIF BU0001.Arid3a_primary
MOTIF MA0151.1 Arid3a
MOTIF MA0601.1 Arid3b
MOTIF ARNT_HUMAN.H11MO.0.B
....
  1. file.sh file containing the script :
#!/bin/bash
while IFS= read -r line || [[ -n $line ]]; do
    fimo --thresh 1e-4 --no-qvalue --max-stored-scores 10000000 --motif $line --text file.meme genome.fa > ResultFile
done < $1
  1. Command line input to start the bash job :
cd /Users/myho2345/Desktop/Motifs_analysis
chmod +x file.sh
./file.sh MotifsList.txt

*Error:

zsh: ./file.sh: bad interpreter: /bin/bash^M: no such file or directory

The scripts are not correct. Where am I doing wrong?

Best and thank you so much for the help!!!!

Upvotes: 0

Views: 112

Answers (1)

Moshe
Moshe

Reputation: 5139

^M is a carriage-return characters in DOS filesystems, it is "invisible".

2 options to fix:

# Option 1
dos2unix file.sh

# Option 2
sed -i 's/\r//g' file.sh

Upvotes: 1

Related Questions