system

Hello community!

I have a question regarding the system command.

Here is the context.

I am writing a batch file.

At some point, I want to classify my otu againts GG, Silva and RDP. The problem is that the file stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons
that is being generated by classify.otu is being rewriten if I am doing the classifications one after the others.

So I tried to use the command system to mv/cp the file to change it’s name so that it is not rewriten each time.

Here is my command line in my batch files:

classify.otu(list=current, count=current, taxonomy=stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pds.wang.taxonomy, label=0.03)
system(mv stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy rdp.agc.unique_list.0.03.cons.taxonomy)

classify.otu(list=current, count=current, taxonomy=stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.gg.wang.taxonomy, label=0.03)
system(cp stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy gg.agc.unique_list.0.03.cons.taxonomy)

classify.otu(list=current, count=current, taxonomy=stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.nr_v123.wang.pick.taxonomy, label=0.03)

make.shared(list=current, count=current, label=0.03)

I am getting the following error message:

system(mv stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy rdp.agc.unique_list.0.03.cons.taxonomy)

mv: cannot stat ‘stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy’: No such file or directory.

Any idea of what can be wrong?

Many thanks.

Could it be something as simple as not having a comma between the thing you are moving/renaming and the new name/directory?

Thanks for the reply.

I have looked in the wiki and for the system I get this.

**
Examples

To copy a file in the Mac/Linux environment:

mothur > system(cp esophagus.unique.bad.accnos esophagus.bad.accnos)
**

I still tried it just in case

mothur > system(cp stability_cocccampy.files, test)
cp: missing destination file operand after ‘stability_cocccampy.files’
Try ‘cp --help’ for more information

it did not work…

It looks like it’s angry at this part:
mv: cannot stat ‘stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy’: No such file or directory.

I’m assuming the file you want to move/rename is
stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy

and the file you want to change it to is
rdp.agc.unique_list.0.03.cons.taxonomy?

If so, try a comma between them
system(mv stability.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy, rdp.agc.unique_list.0.03.cons.taxonomy)

Long shot, but it’s what I’d try first.

I found something: thanks for the idea McCoyk

If I use mothur default directory as input output, no problems at all


mothur > system(cp mothur_alex_analysis.batch test.batch)


if I change the directory, not working


mothur > set.dir(input=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq, output=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq)
Mothur’s directories:
outputDir=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/
inputDir=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/

mothur > system(cp testcopy.txt supertest.txt)
cp: cannot stat ‘testcopy.txt’: No such file or directory


If I try with he full path to the file while having set the input output as my working directory, it works!


mothur > system(cp /home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/testcopy.txt /home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/copytestcopy.txt)


solution: use full path. Counter intuitive but works! i now will try in my batch file.

you can use

system(pwd)

to see what folder you are working in. Esp if you are using setinputdir because you don’t have to be in the working dir

here is the output


mothur > set.dir(input=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq, output=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq)
Mothur’s directories:
outputDir=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/
inputDir=/home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/

mothur > system(pwd)
/home/skynet/Desktop/mothur/mothurv1381


so the system command do not use the input path set in set.dir as the working directory.

thanks!

so in the batch file, it worked like a charm! no errors and the files are there!


mothur > system(cp /home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/stability_cocccampy.trim.contigs.good.unique.good.filter.unique.precluster.pick.pick.agc.unique_list.0.03.cons.taxonomy /home/skynet/Documents/Alex_Thibodeau/miSEQ/coccidie16S/fastq/gg.agc.unique_list.0.03.cons.taxonomy)


set.dir isn’t supposed to change your working directory. Use it when you explicitly don’t want to change your working directory because you want input and output in different directories. Personally, if input and output are the same I move into that directory before beginning my process.