Class: FastaRetriever::Retriever
- Inherits:
-
Object
- Object
- FastaRetriever::Retriever
- Defined in:
- lib/bio-fasta_retrieve.rb
Class Method Summary collapse
-
.compose_fasta(sequence, organism, chr, start_coord, end_coord) ⇒ Object
End parse_xml.
-
.parse_xml(xml) ⇒ Object
parse sequence from xml.
-
.retrieve(organism, chr, start_coord, end_coord) ⇒ Object
input organism, chromosome, start, end separated by space (i.e. hg19 chr10 1000 2000).
-
.ucsc_connect(address) ⇒ Object
connects to ucsc and retrieve xml with DNA sequence.
Instance Method Summary collapse
-
#initialize ⇒ Retriever
constructor
A new instance of Retriever.
Constructor Details
#initialize ⇒ Retriever
Returns a new instance of Retriever.
23 |
# File 'lib/bio-fasta_retrieve.rb', line 23 def initialize;end |
Class Method Details
.compose_fasta(sequence, organism, chr, start_coord, end_coord) ⇒ Object
End parse_xml
47 48 49 50 51 |
# File 'lib/bio-fasta_retrieve.rb', line 47 def self.compose_fasta(sequence,organism,chr,start_coord,end_coord) seq=Bio::Sequence::NA.new(sequence) seq_res=seq.to_fasta("#{organism}_#{chr}_#{start_coord}_#{end_coord}") return seq_res end |
.parse_xml(xml) ⇒ Object
parse sequence from xml
42 43 44 45 |
# File 'lib/bio-fasta_retrieve.rb', line 42 def self.parse_xml(xml) xml_res=xml.xpath("//DNA").text.tr("\n","") return xml_res end |
.retrieve(organism, chr, start_coord, end_coord) ⇒ Object
input organism, chromosome, start, end separated by space (i.e. hg19 chr10 1000 2000)
27 28 29 30 31 32 |
# File 'lib/bio-fasta_retrieve.rb', line 27 def self.retrieve(organism,chr,start_coord,end_coord) address="http://genome.ucsc.edu/cgi-bin/das/#{organism}/dna?segment=#{chr}:#{start_coord},#{end_coord}" xml=ucsc_connect(address) seq=compose_fasta(xml,organism,chr,start_coord,end_coord) return seq end |
.ucsc_connect(address) ⇒ Object
connects to ucsc and retrieve xml with DNA sequence
35 36 37 38 39 |
# File 'lib/bio-fasta_retrieve.rb', line 35 def self.ucsc_connect(address) xml = Nokogiri::XML(open(address)) xml_res=parse_xml(xml) return xml_res end |