Search
Question: Using msa msaPrettyPrint(): saving multiple alignement fasta file
1
gravatar for Olorin
9 months ago by
Olorin50
Olorin50 wrote:

Hello.

I know when I use msaPrettyPrint() function, this write the aligned sequences in fasta file ;

C:/Users/SEBASTIEN/AppData/Local/Temp/RtmpMTD00Y/seq21e072f6414e.fasta

Is there a way to change the ouput directory?

ADD COMMENTlink modified 5 months ago by tongtong.wang12100 • written 9 months ago by Olorin50
2
gravatar for UBodenhofer
9 months ago by
UBodenhofer200
Johannes Kepler University, Linz, Austria
UBodenhofer200 wrote:

Thanks for all the contributions in this thread! The problem is that TeX cannot handle spaces and some special characters in paths, especially on Windows. That may lead to problems with temporary files, but also if the path to the current working directory has some "illegal" characters in it. In case such a problem occurs, use a different working directory the path to which does not have any spaces or other illegal characters. In case this occurs with temporary files, use the 'file' argument to redirect the temporary files. I think this sums up all the previous suggestions. By the way, this is also mentioned in Section 7.8 of the package vignette (page 33 in the current version).

ADD COMMENTlink written 9 months ago by UBodenhofer200
1
gravatar for James W. MacDonald
9 months ago by
United States
James W. MacDonald45k wrote:

Have you looked at the help page for the function you are using? In particular the 'file' argument?

ADD COMMENTlink written 9 months ago by James W. MacDonald45k
1
gravatar for Olorin
9 months ago by
Olorin50
Olorin50 wrote:
I'm trying this 

# #
bdir = "E:/DOCTORAT/workspace/alignement_prot_ribo_all"
workdir = file.path(bdir,"one_file_per_ptne/")
outdir = file.path(bdir,"alignements")

myFiles = list.files(path = workdir,full.names = TRUE)
for (i in 1:66){
  newdir = substr(basename(myFiles[i]), start = 1 ,stop = 6)
  output = file.path(outdir, newdir)
  dir.create(output,showWarnings = FALSE)
  current_seq <- readAAStringSet(myFiles[i])
  current_align <- msa(current_seq)
  fasta_file = paste(outdir,'/',newdir,".aln",sep="")
  pdf_file = paste(outdir,"/" ,newdir,".pdf",sep="")
  msaPrettyPrint(current_align, output="pdf", showNames="none", askForOverwrite=FALSE, verbose=FALSE,
                  file = output, alFile = fasta_file)
}

But there are errors on alFile and file:

Error in msaPrettyPrint(current_align, output = "pdf", showNames = "none",  : 
  The parameter alFile has an invalid argument

If i remove alFile:

Error in msaPrettyPrint(current_align, output = "pdf", showNames = "none",  : 
  The file name suffix and output type do not match!

___________________________________________________________________________________________________

EDIT: Solution for specifying output files names

It's working now, we have to specify both .pdf and .fasta in file name 

  fasta_file = paste(outdir,'/',newdir,".fasta",sep="")
  pdf_file = paste(output,"/",newdir,".pdf",sep="")
  print(pdf_file)
  msaPrettyPrint(current_align, output="pdf", showConsensus = "none", askForOverwrite=FALSE, verbose=FALSE,
                  file = pdf_file, alFile = fasta_file )
}

But my loop is broken with an error:

 Error in texi2dvi(texfile, quiet = !verbose, pdf = identical(output, "pdf"),  : 
  unable to run 'pdflatex' on 'E:/DOCTORAT/workspace/alignement_prot_ribo_all/alignements/L1_all.tex' In addition: Warning message:
running command '"pdflatex" -interaction=nonstopmode "E:/DOCTORAT/workspace/alignement_prot_ribo_all/alignements/L1_all.tex"' had status 1 

If i open tex file with texmaker, the compliation is working... So i don't know whats going wrong

ADD COMMENTlink modified 9 months ago • written 9 months ago by Olorin50
1
gravatar for Olorin
9 months ago by
Olorin50
Olorin50 wrote:

PROBLEM SOLVED:

I have resolved my problems.

1. Save tex file with msaPrettyPrint()

2. Construct pdf with texi2pdf()

bdir = "E:/DOCTORAT/workspace/alignement_prot_ribo_all"
workdir = file.path(bdir,"one_file_per_ptne/")
outdir = file.path(bdir,"alignements")

myFiles = list.files(path = workdir,full.names = TRUE)
for (i in 1:66){
  newdir = substr(basename(myFiles[i]), start = 1 ,stop = 6)
  output = file.path(outdir, newdir)
  dir.create(output,showWarnings = FALSE)
  current_seq <- readAAStringSet(myFiles[i])
  current_align <- msa(current_seq)
  fasta_file = paste(outdir,'/',newdir,".fasta",sep="")
  tex_file = paste(outdir,"/",newdir,".tex",sep="")
  print(pdf_file)
  msaPrettyPrint(current_align, output="tex", showConsensus = "none", askForOverwrite=FALSE, verbose=FALSE,
                  file = tex_file, alFile = fasta_file )
  texi2pdf(tex_file, clean=TRUE)
}
ADD COMMENTlink written 9 months ago by Olorin50
0
gravatar for DigDeep
9 months ago by
DigDeep0
Canada
DigDeep0 wrote:

Hi all,

I have tried the solution, but I receive the following error:
 

Error in .normarg_input_filepath(filepath) :
  'filepath' must be a character vector with no NAs



Unsure of where to go from here...

ADD COMMENTlink written 9 months ago by DigDeep0
1

Can you please provide more information about the exact context in which this error message occurs? Otherwise it is really hard to analyze the situation. If possible, provide a complete minimum working example in which this error occurs in a reproducible way.

ADD REPLYlink written 9 months ago by UBodenhofer200

Indeed, I am using the generic example provided in the msa manual

Here:
 

library(msa)

system.file("tex", "texshade.sty", package="msa")

mySequenceFile <- system.file("examples", "exampleAA.fasta", package="msa")
mySequences <- readAAStringSet(mySequenceFile)
mySequences

myFirstAlignment <- msa(mySequences)
myFirstAlignment

print(myFirstAlignment, show="complete")

msaPrettyPrint(myFirstAlignment, output="pdf", showNames="none",
               showLogo="none", askForOverwrite=FALSE, verbose=FALSE)
 

Error in texi2dvi(texfile, quiet = !verbose, pdf = identical(output, "pdf"),  : 
  unable to run 'pdflatex' on 'myFirstAlignment.tex'
In addition: Warning message:
running command '"pdflatex" -interaction=nonstopmode "myFirstAlignment.tex"' had status 1 

At this point in time I follow the solution provided in this forum...

 

bdir = "Home_space"
workdir = file.path(bdir,"one_file_per_ptne/")
outdir = file.path(bdir,"alignements")

myFiles = list.files(path = workdir,full.names = TRUE)
for (i in 1:66){
  newdir = substr(basename(myFiles[i]), start = 1 ,stop = 6)
  output = file.path(outdir, newdir)
  dir.create(output,showWarnings = FALSE)
  current_seq <- readAAStringSet(myFiles[i])
  current_align <- msa(current_seq)
  fasta_file = paste(outdir,'/',newdir,".fasta",sep="")
  tex_file = paste(outdir,"/",newdir,".tex",sep="")
  print(pdf_file)
  msaPrettyPrint(current_align, output="tex", showConsensus = "none", askForOverwrite=FALSE, verbose=FALSE,
                 file = tex_file, alFile = fasta_file )
  texi2pdf(tex_file, clean=TRUE)
}

But I get this error:

Error in .normarg_input_filepath(filepath) : 
  'filepath' must be a character vector with no NAs
ADD REPLYlink written 9 months ago by DigDeep0
1

The new error message is clear: you do not even have the data and files that are needed to run your code, e.g. the file name vector 'myFiles'. So, you cannot use the solution as it is, but only the general idea of it. And the general idea is to use the 'alFile' argument to avoid possible issues with the name and/or location of the temporary FASTA file to which the alignment is written. Please try the following:

library(msa)

mySequenceFile <- system.file("examples", "exampleAA.fasta", package="msa")
mySequences <- readAAStringSet(mySequenceFile)
mySequences

myFirstAlignment <- msa(mySequences)
myFirstAlignment

msaPrettyPrint(myFirstAlignment, alFile="./myFile.fasta", output="pdf", showNames="none",
               showLogo="none", askForOverwrite=FALSE, verbose=FALSE)

If it works, fine. If not, there might also be an issue with your LaTeX installation. (do you have it at all on your system?) In case the problem persists and you post another error report, please enclose the output of 'sessionInfo()' and also check first whether TeX/LaTeX is installed.

ADD REPLYlink modified 9 months ago • written 9 months ago by UBodenhofer200
0
gravatar for tongtong.wang1210
5 months ago by
tongtong.wang12100 wrote:
Could you please specify what are these three parameters stand for?
what should be included in bdir, workdir and outdir?

bdir = "E:/DOCTORAT/workspace/alignement_prot_ribo_all"
workdir = file.path(bdir,"one_file_per_ptne/")
outdir = file.path(bdir,"alignements")
ADD COMMENTlink written 5 months ago by tongtong.wang12100

These are not directly related to msaPrettyPrint() or any other 'msa' functionality. Olorin used them for his example posted above. He reads FASTA files from 'workdir' and writes the output of msaPrettyPrint() to 'outdir'. 'bdir' is just the base directory, of which 'workdir' and 'outdir' are sub-directories.

ADD REPLYlink written 5 months ago by UBodenhofer200
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.2.0
Traffic: 183 users visited in the last hour