Re: [R-sig-phylo] most efficient way to read trees from huge text file
Hello Emmanuel, Yes, trees come one at a line and your solution is apparently working. Thank you very much, Juan > Hi, > > Le 10/10/2013 21:07, Juan Antonio Balbuena a écrit : > > Hello, > > I need to handle in R 10M trees produced with the program evolver of > > PAML. With a smaller number of trees one could create a multi-phylo > > object with ape as > > > > tree.m <- read.tree("filename.tre") > > > > but this is impractical in this case because it takes all the RAM > > memory. I've tried something like > > > >> library(ape) > >> con = file("evolver.out", open="r") # where evolver.out contains 10M > > trees > >> lin = readLines(con) > >> for (i in 1:length(lin)) { > > + tree <- read.tree(lin[i]) > > Replace the line above by: > > tree <- read.tree(text = lin[i]) > > This may work if PAML has actually written one tree per line (ie, each > tree ends with a '\n'). > > HTH, > > Emmanuel > > > + # my additional syntax mrca analysis etc. here > > + } > > > > But it doesn't work: > > > > Error in file(file, "r") : cannot open the connection > > In addition: Warning messages: > > 1: closing unused connection 3 (evolver.out) > > 2: In file(file, "r") : > >cannot open file 'S6: 0.33544, (S1: 0.02314, S10: 0.02314): > > 0.31230): 0.53388, S5: 0.86932): 0.04830, (S4: 0.51901, (S7: 0.05901, > > S2: 0.05901): 0.46000): 0.39861): 0.08238, (S3: 0.30236, (S8: 0.13236, > > S9: 0.13236): 0.17000): 0.69764);': No such file or directory > > > > I would very much appreciate your help. Note that computing efficiency > > is key here. > > > > Thank you very much for your attention. > > > > Juan A. Balbuena > > > > ___ > > R-sig-phylo mailing list - R-sig-phylo@r-project.org > > https://stat.ethz.ch/mailman/listinfo/r-sig-phylo > > Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/ > > > > ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
Re: [R-sig-phylo] most efficient way to read trees from huge text file
Hi, Le 10/10/2013 21:07, Juan Antonio Balbuena a écrit : Hello, I need to handle in R 10M trees produced with the program evolver of PAML. With a smaller number of trees one could create a multi-phylo object with ape as tree.m <- read.tree("filename.tre") but this is impractical in this case because it takes all the RAM memory. I've tried something like library(ape) con = file("evolver.out", open="r") # where evolver.out contains 10M trees lin = readLines(con) for (i in 1:length(lin)) { + tree <- read.tree(lin[i]) Replace the line above by: tree <- read.tree(text = lin[i]) This may work if PAML has actually written one tree per line (ie, each tree ends with a '\n'). HTH, Emmanuel + # my additional syntax mrca analysis etc. here + } But it doesn't work: Error in file(file, "r") : cannot open the connection In addition: Warning messages: 1: closing unused connection 3 (evolver.out) 2: In file(file, "r") : cannot open file 'S6: 0.33544, (S1: 0.02314, S10: 0.02314): 0.31230): 0.53388, S5: 0.86932): 0.04830, (S4: 0.51901, (S7: 0.05901, S2: 0.05901): 0.46000): 0.39861): 0.08238, (S3: 0.30236, (S8: 0.13236, S9: 0.13236): 0.17000): 0.69764);': No such file or directory I would very much appreciate your help. Note that computing efficiency is key here. Thank you very much for your attention. Juan A. Balbuena ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/ ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/
[R-sig-phylo] most efficient way to read trees from huge text file
Hello, I need to handle in R 10M trees produced with the program evolver of PAML. With a smaller number of trees one could create a multi-phylo object with ape as tree.m <- read.tree("filename.tre") but this is impractical in this case because it takes all the RAM memory. I've tried something like > library(ape) > con = file("evolver.out", open="r") # where evolver.out contains 10M trees > lin = readLines(con) > for (i in 1:length(lin)) { + tree <- read.tree(lin[i]) + # my additional syntax mrca analysis etc. here + } But it doesn't work: Error in file(file, "r") : cannot open the connection In addition: Warning messages: 1: closing unused connection 3 (evolver.out) 2: In file(file, "r") : cannot open file 'S6: 0.33544, (S1: 0.02314, S10: 0.02314): 0.31230): 0.53388, S5: 0.86932): 0.04830, (S4: 0.51901, (S7: 0.05901, S2: 0.05901): 0.46000): 0.39861): 0.08238, (S3: 0.30236, (S8: 0.13236, S9: 0.13236): 0.17000): 0.69764);': No such file or directory I would very much appreciate your help. Note that computing efficiency is key here. Thank you very much for your attention. Juan A. Balbuena ___ R-sig-phylo mailing list - R-sig-phylo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-phylo Searchable archive at http://www.mail-archive.com/r-sig-phylo@r-project.org/