share/install/NCI/Rakefile in rbbt-sources-3.0.19 vs share/install/NCI/Rakefile in rbbt-sources-3.0.20
- old
+ new
@@ -4,38 +4,44 @@
module NCI
def self.get_pathways(xml, format = "UP", get_short_name = false)
doc = Nokogiri::XML(xml)
pathways = {}
+ #{{{ Molecules
+
molecules = {}
doc.xpath("//Molecule").each do |molecule|
id = molecule.attribute('id').value
type = molecule.attribute('molecule_type').value
names = molecule.xpath("Name[@name_type='#{format}']").collect{|name| name.attribute("value").value}
molecules[id] = {:xml => molecule, :proteins => names}
end
+ #{{{ Interactions
+
interactions = {}
doc.xpath("//Interaction").each do |interaction|
id = interaction.attribute('id').value
type = interaction.attribute('interaction_type').value
molecule_ids = interaction.xpath('InteractionComponentList/InteractionComponent').collect{|c| c.attribute('molecule_idref').value}.flatten.compact
pathway_ids = interaction.xpath('Abstraction').collect{|c| c.attribute('pathway_idref').value}.flatten.compact
interactions[id] = {:xml => interaction, :molecule_ids => molecule_ids, :pathway_ids => pathway_ids}
end
+ #{{{ Pathways
+
doc.xpath("//Pathway").each do |pathway|
id = pathway.attribute('id').value
subnet = pathway.attribute('subnet').value
name = pathway.xpath('LongName').first.content
short_name = pathway.xpath('ShortName').first.content if get_short_name
interaction_ids = pathway.xpath("PathwayComponentList/PathwayComponent").collect{|component| component.attribute("interaction_idref").value}
-
pathway_interactions = interaction_ids.collect{|i| interactions[i]}
+
pathway_molecule_ids = pathway_interactions.collect{|info| info[:molecule_ids]}.compact.flatten
pathway_uniprot_ids = pathway_molecule_ids.collect do |i|
next unless molecules.include? i
molecules[i][:proteins]
@@ -45,23 +51,25 @@
else
pathways[id] = [[name], [pathway_uniprot_ids.flatten.compact.uniq]]
end
end
+ #{{{ Sub-pathways ???
+
doc.xpath("//Pathway").each do |pathway|
id = pathway.attribute('id').value
subnet = pathway.attribute('subnet').value
name = pathway.xpath('LongName').first.content
interaction_ids = pathway.xpath("PathwayComponentList/PathwayComponent").collect{|component| component.attribute("interaction_idref").value}
-
pathway_interactions = interaction_ids.collect{|i| interactions[i]}
+
pathway_subnet_ids = pathway_interactions.collect{|info| info[:pathway_ids]}.compact.flatten
pathway_subnet_ids.collect do |nid|
next unless pathways.include? nid
- new_genes = pathways[id].last
- pathways[nid][1] = (pathways[nid][1] + new_genes).uniq
+ new_genes = pathways[nid].last
+ pathways[id][1] = (pathways[id][1] + new_genes).uniq
end
end
pathways
end