error assembly megahit
2
0
Entering edit mode
6.2 years ago

Hi,

I'm trying to make an assembly of several sequences with next command but I have an error

My samples

sample1_1.fq
sample1_2.fq
sample2_1.fq
sample2_2.fq

for i in *.fq ; do /home/fernado/megahit/megahit -1 $i\_1.fq -2 $i\_2.fq  -o assembly$i ; done

16Gb memory in total.

Using: 12Gb.

megahit: Cannot find file assembly_sample1_1.fq_1.fq

I hope you can help

Assembly • 2.8k views
ADD COMMENT
1
Entering edit mode
6.2 years ago
Fabio Marroni ★ 3.0k

You are sending the wrong file names. From the error message I understand that megahit is looking for the file "assembly_sample1_1.fq_1.fq", which doesn't exist

Try this:

for i in *_1.fq
do 
read1=${i/.fq/}
read2=${read1/_1/_2}
/home/fernado/megahit/megahit -1 $read1 -2 $read2  -o assembly$i
done
ADD COMMENT
0
Entering edit mode

Hi, I try as you suggest but it seems that not recognize the key in the script, therefore I have a error

./assembly.sh ./assembly.sh:6: ./assembly.sh: Bad substitution

This the script

 for i in *_1.fq  
 do  
 read1=${i/.fq/} 
 read2=${read1/_1/_2}   
 /home/fernado/megahit/megahit  -1  $read1  -2 $read2 -o assembly$i 
 done
ADD REPLY
0
Entering edit mode

When I changed the key by parentheses it works but does not recognize the files

 for i in *_1.fq 
 do           
 read1=$(i/.fq/)
 read2=$(read1/_1/_2) 
 home/fernado/megahit/megahit  -1  $read1  -2 $read2 -o assembly$i 
 done

For example this the error

/assembly.sh: 6: ./assembly.sh: i/.fq/: not found
/assembly.sh: 7: ./assembly.sh: read1/_1/_2: not found
ADD REPLY
0
Entering edit mode

Sorry... I don't understand what you mean by "it seems that you do not recognize the key and change it by parentheses, but I have a error" Let's debug step by step: try this and let me know if this gives an error.

mkdir test_dir
cd test_dir    
touch sample1_1.fq sample1_2.fq sample2_1.fq sample2_2.fq
    for i in *_1.fq
    do 
    read1=${i/.fq/}
    read2=${read1/_1/_2}
    echo "/home/fernado/megahit/megahit -1 $read1 -2 $read2  -o assembly$i"
    done
ADD REPLY
0
Entering edit mode

copy the script exactly, but there is an error

./assembly.sh                                                                      
./assembly.sh: 6: ./assembly.sh: Bad substitution

And the lines 6 is this:

read1=${i/.fq/}
ADD REPLY
0
Entering edit mode

I am sorry... I don't know what to do. For me it works :-(

However, try to change the way you feed the read name to megahit. Maybe, if you have a few files, you can start by feeding the names by hand and then when you will have figured out the correct way to feed the names you can use automated scripts.

As far as the Bad substitution, try to give a look here

ADD REPLY
0
Entering edit mode

I think my shell is the problem because donĀ“t recognize "{ }", I try to use the script in other computer

ADD REPLY
0
Entering edit mode
6.2 years ago

already worked in this way

#!/bin/bash
for  f1 in *_1.fq 
do            
f2=${fi%%_1.fq}"_2.fq"
/home/fernado/megahit/megahit  -1  $f1  -2 $f2 -o "assembly$fi.out" 
done

Thanks

ADD COMMENT

Login before adding your answer.

Traffic: 2719 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6