rambaut / Seq-Gen

Sequence simulator
51 stars 17 forks source link

Cannot pipe a tree to `seq-gen` #4

Open SamStudio8 opened 7 years ago

SamStudio8 commented 7 years ago

It is not possible to echo a string into seq-gen to use as a tree:

$ echo "(A:0.1,B:0.1,C:0.1);" | /home/sam/ware/Seq-Gen.v1.3.3/source/seq-gen -mGTR                                                                                                                                              
Sequence Generator - seq-gen
Version 1.3.2x
(c) Copyright, 1996-2004 Andrew Rambaut and Nick Grassly
Department of Zoology, University of Oxford
South Parks Road, Oxford OX1 3PS, U.K.

Error reading tree number 1: .

Meanwhile, the following works:

/home/sam/ware/Seq-Gen.v1.3.3/source/seq-gen -mGTR <<< "(A:0.1,B:0.1,C:0.1);"

From what I can tell, this could be caused by multiple calls of feof(stdin) in seq-gen.c or treefile.c? I'm not really sure what the "first pass" of stdin does, as this is also a valid input that produces sequences:

/home/sam/ware/Seq-Gen.v1.3.3/source/seq-gen -mGTR
Sequence Generator - seq-gen
Version 1.3.2x
(c) Copyright, 1996-2004 Andrew Rambaut and Nick Grassly
Department of Zoology, University of Oxford
South Parks Road, Oxford OX1 3PS, U.K.

<CTRL-D>
(A:0.1,B:0.1,C:0.1);
<CTRL-D>
niemasd commented 7 years ago

I am piping trees into Seq-Gen just fine. I believe they need to be in the Phylip format (I had to add a couple lines above my Newick trees to get it to work, should be a fairly simple conversion)

SamStudio8 commented 7 years ago

@niemasd Ah yes, that must be what those additional feof(stdin) calls were looking for. I seem to recall the PHYLIP format has a header line that describes the number of sequences and their length? Although my latter example shows that one can just interactively leave that header blank with a CTRL+D and seq-gen works anyway, so I'm not entirely sure whether the header is used for anything.

lskatz commented 1 month ago

Ah this issue helped a lot. I couldn't pipe an alignment+tree into seq-gen but I can as a command line argument.