Skip to content

Commit

Permalink
biological assembly download option added
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranavkhade committed Jun 29, 2024
1 parent 4ac9b19 commit c801909
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packman/molecule/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def load_structure(filename: str, ftype: str= 'cif') -> Protein:
##################################################################################################
'''

def download_structure(pdbid: str, save_name: str=None, ftype: str='cif'):
def download_structure(pdbid: str, save_name: str=None, ftype: str='cif', biological_assembly: bool = False):
"""This function downloads the 3D protein structure.
Example::
Expand All @@ -495,16 +495,23 @@ def download_structure(pdbid: str, save_name: str=None, ftype: str='cif'):
molecule.download_structure('1prw')
Args:
pdbid (str) : A Unique 4 Letter PDB ID (eg.. 1PRW)
save_name (str) : Save name of the downloaded file (extension will be added automatically depending on the ftype argument).
ftype (str) : Format name ('.cif' or '.pdb')
pdbid (str) : A Unique 4 Letter PDB ID (eg.. 1PRW)
save_name (str) : Save name of the downloaded file (extension will be added automatically depending on the ftype argument).
ftype (str) : Format name ('.cif' or '.pdb')
biological_assembly (bool) : Download biological assemblies in lieu of PDB entry. (Default: False)
"""
import urllib.request as ur

if(ftype == 'cif'):
response=ur.urlopen('https://files.rcsb.org/view/'+pdbid+'.cif')
if(biological_assembly):
response=ur.urlopen('https://files.rcsb.org/view/'+pdbid+'-assembly1.cif')
else:
response=ur.urlopen('https://files.rcsb.org/view/'+pdbid+'.cif')
elif(ftype == 'pdb'):
response=ur.urlopen('https://files.rcsb.org/view/'+pdbid+'.pdb')
if(biological_assembly):
response=ur.urlopen('https://files.rcsb.org/view/'+pdbid+'.pdb1')
else:
response=ur.urlopen('https://files.rcsb.org/view/'+pdbid+'.pdb')
else:
logging.warning('Please provide appropriate "ftype" argument. (cif/pdb).')
return
Expand Down

0 comments on commit c801909

Please sign in to comment.