1

how can I run ClustalW2 without a input FASTA file?

Can I add a pipe to the command? I am currently following section 6.2.1 in the Biopython Tutorial and Cookbook.

David Cain
  • 16,484
  • 14
  • 65
  • 75
El Dude
  • 5,328
  • 11
  • 54
  • 101
  • You must have some sequences you wish to align - are they in memory as `SeqRecord` objects? In memory as a FASTA format string? Something else? – Peter Cock Oct 18 '13 at 20:22

1 Answers1

2

On using Biopython

I'm assuming you wish to use the clustal wrapper, ClustalwCommandLine. As a wrapper, its function is to create the appropriate command line call from an instance.

I think it's often easier to just work with the command line tool directly, using subprocess (and thus skipping Biopython entirely).

stdin in clustalw2

Consulting the clustalw2 documentation, I see no way to pass data from stdin:

        DATA (sequences)

-INFILE=file.ext                             :input sequences.
-PROFILE1=file.ext  and  -PROFILE2=file.ext  :profiles (old alignment).

stdin in clustalo

However, if upgrading to Clustal Omega is an option, you can see in the Clustal Omega documentation that one can pass - to indicate taking input from stdin:

SEQUENCE INPUT:

-i, --in, --infile={<file>,-}
    Multiple sequence input file (- for stdin)

See how do I pass a string in subprocess.Popen for reference, but in short:

from subprocess import Popen, PIPE, STDOUT


proc = Popen(['clustalwo', '-', <...>], stdout=PIPE, stdin=PIPE, stderr=STDOUT)
stdout = p.communicate(input='> Seq one\nATCGCTACGCACTACGTACG...')
Community
  • 1
  • 1
David Cain
  • 16,484
  • 14
  • 65
  • 75