This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Seqaln Function Error While Using Bio3D Package In R

Hello everyone,

I am using a bio3d package from R for sequence alignment. But I am getting some errors while I was running seqaln function, which calls for the installed MUSCLE program. I got the following example from Bio3D tutorial.

pdb <- read.pdb("1bg2")  

s1 <- aa321(pdb$seqres)
s2 <- seq.pdb(pdb)
aln <- seqaln( seqbind(s1, s2), id=c("seqres","atom") )

muscle -in C:\Users\Peter \AppData\Local\Temp\RtmpaGTZAD\filee116a23 -out aln.fa  -
seqtype proteinError in file(file, "r") : cannot open the connection
In addition: Warning message:
In file(file, "r") : cannot open file 'aln.fa': No such file or directory

I don't understand about this error. your help will be much appreciated.

r sequence alignment

2 answers

R cannot read the alignment file aln.fa which should have been generated by muscle. This is because the file was not written to disk. There are 2 possible reasons:

  1. muscle did not run (R cannot find it in your path)
  2. muscle did run, but you do not have permission to write file aln.fa in your current working directory

I was able to reproduce the error on a Linux machine by running R from a directory where I did not have write permission. However, before the error, I saw:

file7c082f8b0189 2 seqs, max length 325, avg  length 324
00:00:00    12 MB(-4%)  Iter   1  100.00%  K-mer dist pass 1
00:00:00    12 MB(-4%)  Iter   1  100.00%  K-mer dist pass 2
00:00:00    14 MB(-4%)  Iter   1  100.00%  Align node       
00:00:00    14 MB(-4%)  Iter   1  100.00%  Root alignment

Since you did not mention seeing these lines, I suspect that muscle did not run at all.

I note that you are working in Windows; unfortunately I have no idea how to add muscle to the path for this OS. Perhaps someone else can help with that.

10 years later, I now have stumbled into this error, too. I am also running this on Windows. Running the printed MUSCLE command manually in cmd.exe revealed the error: For some weird reason, under Windows MUSCLE has different argument flags!

Align FASTA input, write aligned FASTA (AFA) output:
    muscle -align input.fa -output aln.afa

My current workaround: since my sequences are not so complicated I'm using bioconductor's msa package instead.

BiocManager::install('msa')
pdbs <- pdbaln(files, exefile='msa')

As another person running into this problem 10 years later, thank you! This work around worked for me as well.

Log in to answer this question.