Download pool/shard003/Python/0027125_distances.py from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.38 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard003/Python/0027125_distances.py
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard003/Python/0027125_distances.py
-
curl -L -o 0027125_distances.py https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard003/Python/0027125_distances.py
1.38 kB
| import numpy as np | |
| from Bio.PDB import * | |
| def calc_distances_aas(model): | |
| count = 1 | |
| sites = [] | |
| for a in model.get_residues(): | |
| if a.get_resname() == 'SIA': | |
| continue | |
| distances = [] | |
| for b in model.get_residues(): | |
| if b.get_resname() != 'SIA': | |
| distance = b['CA'] - a['CA'] | |
| distances.append(distance) | |
| sites.append(distances) | |
| print(count) | |
| count += 1 | |
| out_file = open('distances.dat', 'w') | |
| for a in sites: | |
| for b in a: | |
| if b == a[-1]: | |
| out_file.write(str(b)) | |
| else: | |
| out_file.write(str(b) + ',') | |
| out_file.write('\n') | |
| out_file.close() | |
| def calc_distances_sia(): | |
| location = np.zeros(3) | |
| for a in model.get_residues(): | |
| if a.get_resname() == "SIA": | |
| for a1 in a: | |
| location += a1.get_coord() | |
| for a in model.get_residues(): | |
| if a.get_resname() == "SIA": | |
| for b in model.get_residues(): | |
| if b.get_resname() != 'SIA': | |
| distances.write(str(np.sqrt(sum((location - b['CA'].get_coord())**2))) + '\n') | |
| def main(): | |
| parser = PDBParser() | |
| structure = parser.get_structure('temp', '3H47_monomer.pdb') | |
| calc_distances_aas(structure[0]) | |
| main() | |