Class: Bio::Ipcress
- Inherits:
-
Object
- Object
- Bio::Ipcress
- Defined in:
- lib/bio/appl/ipcress.rb
Defined Under Namespace
Classes: PrimerSet, Result, Results
Class Method Summary collapse
-
.parse(ipcress_output_string) ⇒ Object
A full Ipcress result looks something like this.
-
.run(primer_set, fasta_file, options = {}) ⇒ Object
Run ipcress.
Class Method Details
.parse(ipcress_output_string) ⇒ Object
A full Ipcress result looks something like this. Parse it into an array of Ipcress::Result objects
** Message: Loaded [1] experiments
Ipcress result
Experiment: AE12_pmid21856836_16S
Primers: A B
Target: gi|335929284|gb|JN048683.1|:filter(unmasked) Methanocella conradii HZ254 16S ribosomal RNA gene, partial sequence
Matches: 19/20 14/15
Product: 502 bp (range 2-10000)
Result type: forward
…AAACTTAAAGGAATTGGCGG.….….….….….…. # forward
||||| ||| |||||| |||-->
5’-AAACTYAAAKGAATTGRCGG-3’ 3’-CRTGTGTGGCGGGCA-5’ # primers
<--| |||||||||||||
.….….….….….….…..CGTGTGTGGCGGGCA… # revcomp – ipcress: gi|335929284|gb|JN048683.1|:filter(unmasked) AE12_pmid21856836_16S 502 A 826 1 B 1313 1 forward – completed ipcress analysis
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bio/appl/ipcress.rb', line 27 def self.parse(ipcress_output_string) results = Results.new ipcress_output_string.split(/\nIpcress result\n--------------\n/m).each_with_index do |result_chunk, index| next if index == 0 # ignore the first chunk since that isn't a result lines = result_chunk.split("\n").collect{|l| l.strip} result = Result.new i=0 result.experiment_name = lines[i].match(/^Experiment: (.+)$/)[1]; i+=1 result.primers = lines[i].match(/^Primers: (.+)$/)[1]; i+=1 result.target = lines[i].match(/^Target: (.+)$/)[1]; i+=1 result.matches = lines[i].match(/^Matches: (.+)$/)[1]; i+=1 result.product = lines[i].match(/^Product: (.+)$/)[1]; i+=1 result.result_type = lines[i].match(/^Result type: (.+)$/)[1] i+= 2 result.forward_matching_sequence = lines[i].match(/^\.\.\.(\w+)\.+ \# forward$/)[1] i+= 2 matching = lines[i].match(/^5'\-(\w+)-3' 3'\-(\w+)-5' \# primers$/) result.forward_primer_sequence = matching[1] result.reverse_primer_sequence = matching[2] i+= 2 result.reverse_matching_sequence = lines[i].match(/^\.+(\w+)\.\.\. \# revcomp$/)[1] i+= 2 matching = lines[i].match(/^ipcress: (\S+) (\S+) (\d+) [AB] (\d+) (\d+) [AB] (\d+) (\d+) (\S+)$/) result.length = matching[3].to_i result.start = matching[4].to_i result.forward_mismatches = matching[5].to_i result.reverse_mismatches = matching[7].to_i results.push result end return results end |
.run(primer_set, fasta_file, options = {}) ⇒ Object
Run ipcress
-
primer_set: a PrimerSet object with defined forward and reverse primers
-
fasta_file: a String path to a fasta file that will be used as template
-
options hash: contains less-used parameters
** :min_distance: the minimum length of product to be amplified (default 100) ** :max_distance: the maxmimum length of product to be amplified (default 1000) ** :ipcress_path: path the ipcress executable (default ‘ipcress’) ** :mismatches: number of mismatches allowable (-m parameter to ipcress binary, default 0)
Return an array of parsed Result objects
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/bio/appl/ipcress.rb', line 76 def self.run(primer_set, fasta_file, ={}) raise unless primer_set.kind_of?(PrimerSet) raise unless fasta_file.kind_of?(String) [:ipcress_path] ||= 'ipcress' Tempfile.open('ipcress') do |tempfile| # Write a tempfile that contains the primer set to be queried primers = primer_set.to_ipcress_format() tempfile.puts primers tempfile.close command = [ [:ipcress_path], ] if [:mismatches] command.push '-m' command.push [:mismatches].to_s end command.push tempfile.path command.push fasta_file Bio::Command.call_command_open3(command) do |stdin, stdout, stderr| out = stdout.read raise stderr.read if out == '' #if there is a problem running ipcress e.g. the fasta file isn't found return parse(out) end end end |