Spaces:
Paused
Paused
Erva Ulusoy commited on
Commit ·
988f84d
1
Parent(s): 42e2260
included protein and go term names in the result df
Browse filesFiles changed (2)
- data/name_info.json.gzAdded+3
- run_prothgt_app.py+21-5
123version https://git-lfs.github.com/spec/v1oid sha256:89f020fe2ea8529d19f1fbe14f79b1fe111024ed3f26ae03b5b7f98e769d7eb5size 30800846 unmodified lines78910111251 unmodified lines64656667686970717216 unmodified lines89909192939495969798991007 unmodified lines1081091101111121131141151161171181191201211221236 unmodified linesfrom datasets import load_datasetimport gdownimport copyclass ProtHGT(torch.nn.Module):def __init__(self, data,hidden_channels, num_heads, num_layers, mlp_hidden_layers, mlp_dropout):51 unmodified linesreturn heterodatadef get_available_proteins(protein_list_file='data/available_proteins.txt'):with open(protein_list_file, 'r') as file:return [line.strip() for line in file.readlines()]def _generate_predictions(heterodata, model, target_type):device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')16 unmodified lines'GO_term_C': 'Cellular Component'}# Get number of GO terms for this categoryn_go_terms = len(heterodata[go_category]['id_mapping'])# Create lists to store the dataall_proteins = []all_go_terms = []all_categories = []all_probabilities = []7 unmodified linesend_idx = (i + 1) * n_go_termsprotein_predictions = predictions[start_idx:end_idx]# Extend the listsall_proteins.extend([protein_id] * n_go_terms)all_go_terms.extend(go_terms)all_categories.extend([go_category_dict[go_category]] * n_go_terms)all_probabilities.extend(protein_predictions.tolist())# Create DataFrameprediction_df = pd.DataFrame({'Protein': all_proteins,'GO_term': all_go_terms,'GO_category': all_categories,'Probability': all_probabilities})6 unmodified lines789101112131451 unmodified lines6667686970717273747516 unmodified lines92939495969798991001011021031041051061071081097 unmodified lines1171181191201211221231241251261271281291301311321331341351361371381396 unmodified linesfrom datasets import load_datasetimport gdownimport copyimport jsonimport gzipclass ProtHGT(torch.nn.Module):def __init__(self, data,hidden_channels, num_heads, num_layers, mlp_hidden_layers, mlp_dropout):51 unmodified linesreturn heterodatadef get_available_proteins(name_file='data/name_info.json.gz'):with gzip.open(name_file, 'rt', encoding='utf-8') as file:name_info = json.load(file)return list(name_info['Protein'].keys())def _generate_predictions(heterodata, model, target_type):device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')16 unmodified lines'GO_term_C': 'Cellular Component'}# Load name information from gzipped filewith gzip.open('data/name_info.json.gz', 'rt', encoding='utf-8') as file:name_info = json.load(file)# Get number of GO terms for this categoryn_go_terms = len(heterodata[go_category]['id_mapping'])# Create lists to store the dataall_proteins = []all_protein_names = []all_go_terms = []all_go_term_names = []all_categories = []all_probabilities = []7 unmodified linesend_idx = (i + 1) * n_go_termsprotein_predictions = predictions[start_idx:end_idx]# Get protein nameprotein_name = name_info['Protein'].get(protein_id, protein_id)# Extend the listsall_proteins.extend([protein_id] * n_go_terms)all_protein_names.extend([protein_name] * n_go_terms)all_go_terms.extend(go_terms)all_go_term_names.extend([name_info['GO_term'].get(term_id, term_id) for term_id in go_terms])all_categories.extend([go_category_dict[go_category]] * n_go_terms)all_probabilities.extend(protein_predictions.tolist())# Create DataFrameprediction_df = pd.DataFrame({'UniProt_ID': all_proteins,'Protein': all_protein_names,'GO_ID': all_go_terms,'GO_term': all_go_term_names,'GO_category': all_categories,'Probability': all_probabilities})
data/name_info.json.gzAdded+3
run_prothgt_app.py+21-5