Skip to content
Back to formatted view

Raw Message

Message-ID: <4EF3FF32.2090208@fhcrc.org>
Date: 2011-12-23T04:10:26Z
From: Martin Morgan
Subject: [Bioc-devel] Rsamtools Reading TabixFile URL
In-Reply-To: <20111223133009.BPS32751@gimr.garvan.unsw.edu.au>

On 12/22/2011 06:30 PM, Dario Strbenac wrote:
>> The '301' error is generally file not found. If I open the URL in a
>> browser I'm redirected to
>>
>>    url = "http://genomesavant.com/savant//data/hg18/hg18.refGene.gz"
>>
>> and things work out
>
> Ah, OK. I'm getting the file path from another program, though. Is there any way for R to follow redirected URLs, as I have no way in R of knowing that it is a redirect or where it points to. Can R work with these URLs in any other way ?

You could use RCurl to figure out the updated location, along the lines of

library(RCurl)
h <- basicTextGatherer()
res <- curlPerform(URL=url, followlocation=FALSE,
                    headerfunction=h$update)
sub(".*Location: ([^[:cntrl:]]+).*", "\\1", h$value())

Martin

> Thanks,
>         Dario.


-- 
Computational Biology
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N. PO Box 19024 Seattle, WA 98109

Location: M1-B861
Telephone: 206 667-2793