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}}
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
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
>
>
>
>
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}}