Sequence output formatting
2
0
Entering edit mode
Daniel Brewer ★ 1.9k
@daniel-brewer-1791
Last seen 10.2 years ago
Just a quick question. Is there any way to stop the "[1]" outputting when printing to a file? I am trying to create a fasta format file using the following: sink(file = "fastaseq.txt") for (i in 1:length(acc)) { print(paste(">",acc[i],sep="")) print(getSEQ(acc[i])) } sink(file = NULL) Thanks Dan -- ************************************************************** Daniel Brewer, Ph.D. Institute of Cancer Research Molecular Carcinogenesis Email: daniel.brewer at icr.ac.uk ************************************************************** The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP. This e-mail message is confidential and for use by the addre...{{dropped}}
Cancer Cancer • 1.2k views
ADD COMMENT
0
Entering edit mode
@jdelasherasedacuk-1189
Last seen 9.3 years ago
United Kingdom
Quoting Daniel Brewer <daniel.brewer at="" icr.ac.uk="">: > Just a quick question. Is there any way to stop the "[1]" outputting > when printing to a file? > > I am trying to create a fasta format file using the following: > sink(file = "fastaseq.txt") > for (i in 1:length(acc)) > { > print(paste(">",acc[i],sep="")) > print(getSEQ(acc[i])) > } > sink(file = NULL) > > Thanks > > Dan Not sure if this is the best way, but you can create a character variable for your text, and use write.table to save it into a text file. That's the method I use in a couple of functions I made to do stuff with DNA sequences and it works. Jose -- Dr. Jose I. de las Heras Email: J.delasHeras at ed.ac.uk The Wellcome Trust Centre for Cell Biology Phone: +44 (0)131 6513374 Institute for Cell & Molecular Biology Fax: +44 (0)131 6507360 Swann Building, Mayfield Road University of Edinburgh Edinburgh EH9 3JR UK
ADD COMMENT
0
Entering edit mode
You might also want to look at ?cat, e.g. cat(paste(">",acc[i],sep=""),"\n") might do what you want (you need the "\n" to get a newline character). Richard. J.delasHeras at ed.ac.uk wrote: > Quoting Daniel Brewer <daniel.brewer at="" icr.ac.uk="">: > > >> Just a quick question. Is there any way to stop the "[1]" outputting >> when printing to a file? >> >> I am trying to create a fasta format file using the following: >> sink(file = "fastaseq.txt") >> for (i in 1:length(acc)) >> { >> print(paste(">",acc[i],sep="")) >> print(getSEQ(acc[i])) >> } >> sink(file = NULL) >> >> Thanks >> >> Dan >> > > Not sure if this is the best way, but you can create a character > variable for your text, and use write.table to save it into a text > file. That's the method I use in a couple of functions I made to do > stuff with DNA sequences and it works. > > Jose > > > >
ADD REPLY
0
Entering edit mode
Tobias Straub ▴ 430
@tobias-straub-2182
Last seen 10.2 years ago
I'd recommend using sth like con <- file("fastaseq.txt", open="wt") for (i in 1:length(acc)) { writeLines(paste(">",acc[i],sep="")) writeLines(getSEQ(acc[i])) } close(con) imho, sink is not done for what you want it to do Tobias On Jul 9, 2007, at 4:45 PM, Daniel Brewer wrote: > Just a quick question. Is there any way to stop the "[1]" outputting > when printing to a file? > > I am trying to create a fasta format file using the following: > sink(file = "fastaseq.txt") > for (i in 1:length(acc)) > { > print(paste(">",acc[i],sep="")) > print(getSEQ(acc[i])) > } > sink(file = NULL) > > Thanks > > Dan > -- > ************************************************************** > Daniel Brewer, Ph.D. > Institute of Cancer Research > Molecular Carcinogenesis > Email: daniel.brewer at icr.ac.uk > ************************************************************** > > The Institute of Cancer Research: Royal Cancer Hospital, a > charitable Company Limited by Guarantee, Registered in England > under Company No. 534147 with its Registered Office at 123 Old > Brompton Road, London SW7 3RP. > > This e-mail message is confidential and for use by the add...{{dropped}}
ADD COMMENT
0
Entering edit mode
sorry... forgot something: I'd recommend using sth like con <- file("fastaseq.txt", open="wt") for (i in 1:length(acc)) { writeLines(paste(">",acc[i],sep=""), con, sep="\n") writeLines(getSEQ(acc[i]), con, sep="\n") } close(con) On Jul 9, 2007, at 5:26 PM, Tobias Straub wrote: > I'd recommend using sth like > > con <- file("fastaseq.txt", open="wt") > for (i in 1:length(acc)) > { > writeLines(paste(">",acc[i],sep="")) > writeLines(getSEQ(acc[i])) > } > close(con) ====================================================================== Dr. Tobias Straub Adolf-Butenandt-Institute, Molecular Biology tel: +49-89-2180 75 439 Schillerstr. 44, 80336 Munich, Germany
ADD REPLY

Login before adding your answer.

Traffic: 511 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6