Hi Everyone,

Thanks for all the responses to my question about “find and replace” for my 
very large newick strings.  This function (thanks to Christie):  
gsub("(?<=\\)).*?(?=\\:|\\;)", "", my_newick_string, perl=T) seems to do the 
the trick.  But thanks to everyone else who responded with other helpful tips.

Cheers,
Karen


On Aug 24, 2015, at 11:35 AM, Karen Gordon <[email protected]> wrote:

> Hi There,
> 
> I’m currently wanting to make some changes to some phylogenies in R by 
> reading in the newick text as a string, rather than as a phylo object.  The 
> reason is that the trees are large (~10,000 tips and another set with ~5000 
> tips) and I must make changes to a complete set of these tree (i.e. 10,000 
> trees).  Currently, these trees have node labels, which I’d like to remove.  
> 
> Essentially what I’d like to do is substitute “)?:” with “):” or simply 
> delete "?", where “?" is any and all characters that occur between the 
> “close” parenthesis and the colon.  So far I found I could use the function 
> ’sub’ but I’d like to make the replacements in one fell swoop, without 
> knowing what the node labels are in advance.  Also the sub function seems to 
> only replace the first occurrence of the pattern rather than all matches in a 
> string.  Any suggestions would be greatly appreciated!  Thank you!
> 
> best,
> Karen
> 
> 
> 

_______________________________________________
R-sig-phylo mailing list - [email protected]
https://stat.ethz.ch/mailman/listinfo/r-sig-phylo
Searchable archive at http://www.mail-archive.com/[email protected]/

Reply via email to