Top Level Namespace
Defined Under Namespace
Modules: DomFun
Instance Method Summary collapse
- #add_term2dictionary(dict, key, term) ⇒ Object
- #load_cafa_data(cafa_file) ⇒ Object
- #load_cath_data(file, category, meth = 'protACC') ⇒ Object
- #load_proteins_file(file, annotation_types) ⇒ Object
Instance Method Details
#add_term2dictionary(dict, key, term) ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/DomFun/generalMethods.rb', line 78 def add_term2dictionary(dict, key, term) query = dict[key] if query.nil? dict[key] = [term] else query << term end end |
#load_cafa_data(cafa_file) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/DomFun/generalMethods.rb', line 87 def load_cafa_data(cafa_file) cafa_data = {} File.open(cafa_file).each do |line| line.chomp! next if line.include?('GO_Ont') cafa_info = line.split("\t") next unless cafa_info[1] == 'MF' go_term = cafa_info[4] gene_name = cafa_info[6] next if gene_name == 'NA' query = cafa_data[gene_name] if query.nil? cafa_data[gene_name] = [go_term] else query << go_term end end return cafa_data end |
#load_cath_data(file, category, meth = 'protACC') ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/DomFun/generalMethods.rb', line 40 def load_cath_data(file, category, meth='protACC') cath_data = {} protein2gene = {} gene2proteins = {} csv_file = CSV.read(file, { :col_sep => "\t" }) csv_file.delete_at(0) csv_file.each do |protein_domains_data| next if protein_domains_data.empty? protein_id = protein_domains_data[0] if meth == 'protACC' field = 3 elsif meth == 'geneID' field = 4 end gene_name = protein_domains_data[field] next if gene_name.include?('fusion') gene_name = gene_name.gsub(' ', '_') if gene_name.include?(' ') superfamilyID = protein_domains_data[5] funfamID = protein_domains_data[6] term2save = nil if category == 'superfamilyID' term2save = superfamilyID elsif category == 'funfamID' term2save = funfamID end add_term2dictionary(cath_data, protein_id, term2save) protein2gene[protein_id] = gene_name if gene_name != 'NULL' query = gene2proteins[gene_name] if query.nil? gene2proteins[gene_name] = [protein_id] if protein_id != 'NULL' else query << protein_id if protein_id != 'NULL' end end cath_proteins_number = cath_data.keys.length return cath_data, protein2gene, gene2proteins, cath_proteins_number end |
#load_proteins_file(file, annotation_types) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/DomFun/generalMethods.rb', line 1 def load_proteins_file(file, annotation_types) protein_annotations = {} proteins_without_annotations = [] annotation_types.each do |type| # initialize annotation hashes protein_annotations[type] = {} end counter = 0 File.open(file).each do |line| line.chomp! if counter == 0 counter += 1 next end line.gsub!(' ', '') fields = line.split("\t", 4) protID = fields.shift annotation_types.each_with_index do |type, i| annotations = fields[i].split(/[;,]/) if !annotations.empty? if type.include?('go') go_annotations = [] annotations.each do |go_term| go_name, go_id = go_term.split('GO:') go_annotations << "GO:".concat(go_id.tr(']', '')) unless go_id.nil? end protein_annotations[type][protID] = go_annotations else protein_annotations[type][protID] = annotations end end if fields.count("") == 3 proteins_without_annotations << protID end end counter += 1 end return protein_annotations, counter, proteins_without_annotations.uniq end |