Question: error assembly megahit
0
gravatar for fernandoavila3428
8 months ago by
fernandoavila34280 wrote:

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 • 474 views
ADD COMMENTlink modified 8 months ago • written 8 months ago by fernandoavila34280
1
gravatar for Fabio Marroni
8 months ago by
Fabio Marroni2.2k
Italy
Fabio Marroni2.2k wrote:

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 COMMENTlink written 8 months ago by Fabio Marroni2.2k

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 REPLYlink modified 8 months ago • written 8 months ago by fernandoavila34280

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 REPLYlink modified 8 months ago • written 8 months ago by fernandoavila34280

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 REPLYlink modified 8 months ago • written 8 months ago by Fabio Marroni2.2k

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 REPLYlink written 8 months ago by fernandoavila34280

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 REPLYlink written 8 months ago by Fabio Marroni2.2k

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

ADD REPLYlink written 8 months ago by fernandoavila34280
0
gravatar for fernandoavila3428
8 months ago by
fernandoavila34280 wrote:

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 COMMENTlink modified 8 months ago • written 8 months ago by fernandoavila34280
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 996 users visited in the last hour