[Bioc-devel] Rsamtools Reading TabixFile URL

Martin Morgan mtmorgan at fhcrc.org
Fri Dec 23 05:10:26 CET 2011


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



More information about the Bioc-devel mailing list