Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pjotrp/bioruby-rdf
Browse files Browse the repository at this point in the history
  • Loading branch information
pjotrp committed Jul 26, 2014
2 parents b089e83 + 47b72eb commit eccc96e
Showing 1 changed file with 39 additions and 27 deletions.
66 changes: 39 additions & 27 deletions lib/bio-rdf/extra/gwp.rb
Expand Up @@ -49,35 +49,47 @@ def Blast::parse(name,cluster,buf)

r = {}
r[:id] = name + '_' + cluster + '_' + gene
r[:cluster] = ('gwp:'+clusterid).to_sym
r['a'] = :blast_match
# r[:species] = species
# r[:source] = type
hfull = a[0]
if hfull !~ /_(DNA|CDS|EST)/
hfull = /\[(\S+_(CDS|DNA|EST))\]/.match(buf)[1]
r["gwp:cluster"] = ('gwp:'+clusterid).to_sym
species_match = (buf =~ /\S+_(CDS|DNA|EST)/)
if species_match
r['a'] = :species_match
else
r['a'] = :refseq_match
end
raise "Expected Ss_TYPE (e.g., Mi_CDS) instead of #{hfull} for "+buf if hfull !~ /\S\S_(CDS|DNA|EST)/
r[:homolog_species] = hfull.split.map { |w| w[0] }.join('')
r[:homolog_gene] = gene
hcluster = /(cluster\d+)/.match(descr)[1]
# $stderr.print hcluster,"\n"
raise "Missing cluster for "+buf if not hcluster
r[:homolog_cluster] = ('gwp:'+hfull+'_'+hcluster).to_sym
raise "Illegal hcluster <#{r[:homolog_cluster]}> for "+buf if r[:homolog_cluster] =~ /\s/
r[:descr] = descr
r[:e_value] = a[4].to_f
# p "HERE",descr
if descr =~ /(\[(\w+)_(DNA|CDS|EST)\])/ or hfull =~ /((\w+)_(DNA|CDS|EST))/
r[:homolog_species_full] = $1
r[:homolog_species] = $2
r[:homolog_source] = $3
hfull = a[0]
if species_match
if hfull !~ /_(DNA|CDS|EST)/
hfull = /\[(\S+_(CDS|DNA|EST))\]/.match(buf)[1]
end
raise "Expected Ss_TYPE (e.g., Mi_CDS) instead of #{hfull} for "+buf if hfull !~ /\S\S_(CDS|DNA|EST)/
r[:homolog_species] = hfull.split.map { |w| w[0] }.join('')
r[:homolog_gene] = gene
hcluster = /(cluster\d+)/.match(descr)[1]
# $stderr.print hcluster,"\n"
raise "Missing cluster for "+buf if not hcluster
r[:homolog_cluster] = ('gwp:'+hfull+'_'+hcluster).to_sym
raise "Illegal hcluster <#{r[:homolog_cluster]}> for "+buf if r[:homolog_cluster] =~ /\s/
r[:descr] = descr
r[:e_value] = a[4].to_f
# p "HERE",descr
if descr =~ /(\[(\w+)_(DNA|CDS|EST)\])/ or hfull =~ /((\w+)_(DNA|CDS|EST))/
r[:homolog_species_full] = $1
r[:homolog_species] = $2
r[:homolog_source] = $3
end
r[:homolog_species_full] = hfull.sub(/\[|\]/,"") # remove brackets
# assertions
raise "Error <#{r[:homolog_source]}> "+buf if not /(CDS|DNA|EST)$/.match(r[:homolog_source])
raise "Error <#{r[:homolog_species_full]}> "+buf if not /\w+_(CDS|DNA|EST)$/.match(r[:homolog_species_full])
raise "Error "+buf if not /\S\S_(CDS|DNA|EST)_cluster\d+$/.match(r[:homolog_cluster])
else
# refseq match
r[:homolog_species] = hfull.split.map { |w| w[0] }.join('')
r[:homolog_gene] = gene
r[:descr] = descr
r[:e_value] = a[4].to_f
r[:homolog_species_full] = hfull.sub(/\[|\]/,"") # remove brackets
end
r[:homolog_species_full] = hfull.sub(/\[|\]/,"") # remove brackets
# assertions
raise "Error <#{r[:homolog_source]}> "+buf if not /(CDS|DNA|EST)$/.match(r[:homolog_source])
raise "Error <#{r[:homolog_species_full]}> "+buf if not /\w+_(CDS|DNA|EST)$/.match(r[:homolog_species_full])
raise "Error "+buf if not /\S\S_(CDS|DNA|EST)_cluster\d+$/.match(r[:homolog_cluster])
# override species
recs << r
end
Expand Down

0 comments on commit eccc96e

Please sign in to comment.