99from requests_html import HTMLSession
1010import requests
1111from bs4 import BeautifulSoup
12+ from .enums import FileType
1213
1314
1415class Alphafold_DB :
@@ -40,11 +41,13 @@ def check_structure(self, uniprot_id: str) -> bool:
4041
4142 """
4243 uniprot_id = uniprot_id .upper ()
43- url = self .make_url (uniprot_id , " pdb" )
44+ url = self .make_url (uniprot_id , FileType . pdb )
4445 r = requests .get (url )
4546 return r .status_code != 404
4647
47- def get_file_url (self , uniprot_id : str , filetype : str = "cif" ) -> str :
48+ def get_file_url (
49+ self , uniprot_id : str , filetype : FileType = FileType .cif
50+ ) -> str :
4851 """
4952 Get file url relative to an id from the the Alphafold entry page
5053
@@ -56,6 +59,7 @@ def get_file_url(self, uniprot_id: str, filetype: str = "cif") -> str:
5659 The URL of the file to download
5760
5861 """
62+ filetype = FileType (filetype )
5963
6064 # Do we recognise the filetpye, otherwise raise an exception.
6165 if filetype in ["pdb" , "cif" ]:
@@ -77,7 +81,9 @@ def get_file_url(self, uniprot_id: str, filetype: str = "cif") -> str:
7781 # Return the URL
7882 return url ["href" ]
7983
80- def make_url (self , uniprot_id : str , filetype : str = "cif" ) -> str :
84+ def make_url (
85+ self , uniprot_id : str , filetype : FileType = FileType .cif
86+ ) -> str :
8187 """
8288 Make the URL for the protein
8389
@@ -89,6 +95,7 @@ def make_url(self, uniprot_id: str, filetype: str = "cif") -> str:
8995 The URL of the file to download
9096
9197 """
98+ filetype = FileType (filetype )
9299
93100 uniprot_id = uniprot_id .upper ()
94101 af_id = "AF-" + uniprot_id + "-F1"
@@ -109,7 +116,7 @@ def make_url(self, uniprot_id: str, filetype: str = "cif") -> str:
109116 def get_pdb (
110117 self ,
111118 uniprot_id : str ,
112- filetype : str = " cif" ,
119+ filetype : FileType = FileType . cif ,
113120 ) -> tuple :
114121 """
115122 Returns pdb/cif as strings, saves to file if requested.
@@ -123,6 +130,7 @@ def get_pdb(
123130 Tuple containing the filename and file from the database
124131
125132 """
133+ filetype = FileType (filetype )
126134 # af_id = self.df.loc[self.df['Uniprot_ID'] == uniprot_id.upper()]["AF_ID"].to_numpy()[0]
127135 # version = self.df.loc[self.df['Uniprot_ID'] == uniprot_id.upper()]["version"].to_numpy()[0]
128136 # af_id = "AF-"+uniprot_id+"-F1"
0 commit comments