Skip to content

Commit ff8d4a5

Browse files
author
James Parkhurst
authored
Merge pull request #62 from jmp1985/main
Updated links from alan turing institute to ccpem
2 parents 89cdcc2 + 155bfa8 commit ff8d4a5

File tree

10 files changed

+86
-50
lines changed

10 files changed

+86
-50
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,20 @@ All types of contributions are encouraged and valued. See the [Table of Contents
2929
## Code of Conduct
3030

3131
This project and everyone participating in it is governed by the
32-
[profet Code of Conduct](https://github.com/alan-turing-institute/profetblob/master/CODE_OF_CONDUCT.md).
32+
[profet Code of Conduct](https://github.com/ccpem/profetblob/master/CODE_OF_CONDUCT.md).
3333
By participating, you are expected to uphold this code. Please report unacceptable behavior
3434
to <>.
3535

3636

3737
## I Have a Question
3838

39-
> If you want to ask a question, we assume that you have read the available [Documentation](https://github.com/alan-turing-institute/profet).
39+
> If you want to ask a question, we assume that you have read the available [Documentation](https://github.com/ccpem/profet).
4040
41-
Before you ask a question, it is best to search for existing [Issues](https://github.com/alan-turing-institute/profet/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
41+
Before you ask a question, it is best to search for existing [Issues](https://github.com/ccpem/profet/issues) that might help you. In case you have found a suitable issue and still need clarification, you can write your question in this issue. It is also advisable to search the internet for answers first.
4242

4343
If you then still feel the need to ask a question and need clarification, we recommend the following:
4444

45-
- Open an [Issue](https://github.com/alan-turing-institute/profet/issues/new).
45+
- Open an [Issue](https://github.com/ccpem/profet/issues/new).
4646
- Provide as much context as you can about what you're running into.
4747
- Provide project and platform versions (nodejs, npm, etc), depending on what seems relevant.
4848

@@ -61,8 +61,8 @@ We will then take care of the issue as soon as possible.
6161
A good bug report shouldn't leave others needing to chase you up for more information. Therefore, we ask you to investigate carefully, collect information and describe the issue in detail in your report. Please complete the following steps in advance to help us fix any potential bug as fast as possible.
6262

6363
- Make sure that you are using the latest version.
64-
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://github.com/alan-turing-institute/profet). If you are looking for support, you might want to check [this section](#i-have-a-question)).
65-
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/alan-turing-institute/profetissues?q=label%3Abug).
64+
- Determine if your bug is really a bug and not an error on your side e.g. using incompatible environment components/versions (Make sure that you have read the [documentation](https://github.com/ccpem/profet). If you are looking for support, you might want to check [this section](#i-have-a-question)).
65+
- To see if other users have experienced (and potentially already solved) the same issue you are having, check if there is not already a bug report existing for your bug or error in the [bug tracker](https://github.com/ccpem/profetissues?q=label%3Abug).
6666
- Also make sure to search the internet (including Stack Overflow) to see if users outside of the GitHub community have discussed the issue.
6767
- Collect information about the bug:
6868
- Stack trace (Traceback)
@@ -76,7 +76,7 @@ A good bug report shouldn't leave others needing to chase you up for more inform
7676

7777
We use GitHub issues to track bugs and errors. If you run into an issue with the project:
7878

79-
- Open an [Issue](https://github.com/alan-turing-institute/profet/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
79+
- Open an [Issue](https://github.com/ccpem/profet/issues/new). (Since we can't be sure at this point whether it is a bug or not, we ask you not to talk about a bug yet and not to label the issue.)
8080
- Explain the behavior you would expect and the actual behavior.
8181
- Please provide as much context as possible and describe the *reproduction steps* that someone else can follow to recreate the issue on their own. This usually includes your code. For good bug reports you should isolate the problem and create a reduced test case.
8282
- Provide the information you collected in the previous section.
@@ -95,14 +95,14 @@ This section guides you through submitting an enhancement suggestion for profet,
9595
#### Before Submitting an Enhancement
9696

9797
- Make sure that you are using the latest version.
98-
- Read the [documentation](https://github.com/alan-turing-institute/profet) carefully and find out if the functionality is already covered.
99-
- Perform a [search](https://github.com/alan-turing-institute/profet/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
98+
- Read the [documentation](https://github.com/ccpem/profet) carefully and find out if the functionality is already covered.
99+
- Perform a [search](https://github.com/ccpem/profet/issues) to see if the enhancement has already been suggested. If it has, add a comment to the existing issue instead of opening a new one.
100100
- Find out whether your idea fits with the scope and aims of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Keep in mind that we want features that will be useful to the majority of our users and not just a small subset. If you're just targeting a minority of users, consider writing an add-on/plugin library.
101101

102102
<!-- omit in toc -->
103103
#### How Do I Submit a Good Enhancement Suggestion?
104104

105-
Enhancement suggestions are tracked as [GitHub issues](https://github.com/alan-turing-institute/profet/issues).
105+
Enhancement suggestions are tracked as [GitHub issues](https://github.com/ccpem/profet/issues).
106106

107107
- Use a **clear and descriptive title** for the issue to identify the suggestion.
108108
- Provide a **step-by-step description of the suggested enhancement** in as many details as possible.

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ A Python 3 **pro**tein structure **fet**cher. Retrieves the cif or pdb files fr
55
[![PyPI version shields.io](https://img.shields.io/pypi/v/profet.svg)](https://pypi.python.org/pypi/profet/)
66
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/profet.svg)](https://pypi.python.org/pypi/profet/)
77

8-
[![Building](https://github.com/alan-turing-institute/profet/actions/workflows/python-package.yml/badge.svg)](https://github.com/alan-turing-institute/profet/actions/workflows/python-package.yml)
9-
[![Publishing](https://github.com/alan-turing-institute/profet/actions/workflows/python-publish.yml/badge.svg)](https://github.com/alan-turing-institute/profet/actions/workflows/python-publish.yml)
10-
[![Documentation](https://github.com/alan-turing-institute/profet/actions/workflows/sphinx.yml/badge.svg)](https://github.com/alan-turing-institute/profet/actions/workflows/sphinx.yml)
8+
[![Building](https://github.com/ccpem/profet/actions/workflows/python-package.yml/badge.svg)](https://github.com/ccpem/profet/actions/workflows/python-package.yml)
9+
[![Publishing](https://github.com/ccpem/profet/actions/workflows/python-publish.yml/badge.svg)](https://github.com/ccpem/profet/actions/workflows/python-publish.yml)
10+
[![Documentation](https://github.com/ccpem/profet/actions/workflows/sphinx.yml/badge.svg)](https://github.com/ccpem/profet/actions/workflows/sphinx.yml)
1111

1212
## Dependencies
1313

@@ -38,7 +38,7 @@ pip install profet
3838
To install the development version, which contains the latest features and fixes, install directly from GitHub using:
3939

4040
```sh
41-
pip install git+git://github.com/alan-turing-institute/profet
41+
pip install git+git://github.com/ccpem/profet
4242
```
4343

4444
To test the installation, you need to have pytest and pytest-cov packagages installed which can be done as follows.
@@ -128,11 +128,11 @@ a .pdb file. The file will be cached in the "~/.pdb" directory for future use.
128128

129129
## Documentation
130130

131-
You can find more documentation including a description of the python api [here](https://alan-turing-institute.github.io/profet/).
131+
You can find more documentation including a description of the python api [here](https://ccpem.github.io/profet/).
132132

133133
## Issues and Feature Requests
134134

135-
If you run into an issue, or if you find a workaround for an existing issue, we would very much appreciate it if you could post your question or code as a [GitHub issue](https://github.com/alan-turing-institute/profet/issues).
135+
If you run into an issue, or if you find a workaround for an existing issue, we would very much appreciate it if you could post your question or code as a [GitHub issue](https://github.com/ccpem/profet/issues).
136136

137137
## Contributions
138138

docs/source/installation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fixes, install directly from GitHub using:
1212

1313
.. code-block:: bash
1414
15-
pip install git+git://github.com/alan-turing-institute/profet`
15+
pip install git+git://github.com/ccpem/profet`
1616
1717
Test the installation, navigate to the root directory and run
1818

profet/alphafold.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from requests_html import HTMLSession
1010
import requests
1111
from bs4 import BeautifulSoup
12+
from .enums import FileType
1213

1314

1415
class 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"
@@ -101,15 +108,15 @@ def make_url(self, uniprot_id: str, filetype: str = "cif") -> str:
101108
+ "-model_v"
102109
+ str(version)
103110
+ "."
104-
+ filetype
111+
+ filetype.name
105112
)
106113

107114
return url
108115

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"

profet/cache.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
from .enums import FileType
34

45

56
class PDBFileCache(object):
@@ -35,7 +36,7 @@ def __init__(self, directory: str = None):
3536
# The manifest filename
3637
self.manifest = os.path.join(self.directory, "manifest.txt")
3738

38-
def path(self, uniprot_id: str, filetype: str = "cif") -> str:
39+
def path(self, uniprot_id: str, filetype: FileType = FileType.cif) -> str:
3940
"""
4041
Get the proposed path
4142
@@ -47,6 +48,7 @@ def path(self, uniprot_id: str, filetype: str = "cif") -> str:
4748
The absolute path
4849
4950
"""
51+
filetype = FileType(filetype)
5052
assert filetype in ["pdb", "cif"]
5153
return os.path.join(self.directory, uniprot_id.lower()) + "." + filetype
5254

@@ -64,7 +66,7 @@ def find(self, uniprot_id: str) -> list:
6466
return [
6567
filename
6668
for filename in [
67-
self.path(uniprot_id, filetype) for filetype in ["pdb", "cif"]
69+
self.path(uniprot_id, filetype) for filetype in FileType
6870
]
6971
if os.path.exists(filename)
7072
]
@@ -137,7 +139,11 @@ def items(self):
137139
yield uniprot_id, self.path(uniprot_id, filetype[1:])
138140

139141
def _update_manifest(
140-
self, uniprot_id: str, fileorigin: str, filetype: str, filename: str
142+
self,
143+
uniprot_id: str,
144+
fileorigin: str,
145+
filetype: FileType,
146+
filename: str,
141147
):
142148
"""
143149
Update the manifest file
@@ -149,6 +155,7 @@ def _update_manifest(
149155
filename: The filename
150156
151157
"""
158+
filetype = FileType(filetype)
152159

153160
# Read the current manifest
154161
if os.path.exists(self.manifest):

profet/enums.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from enum import Enum
2+
3+
4+
class FileType(str, Enum):
5+
pdb = "pdb"
6+
cif = "cif"

profet/pdb.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from urllib.request import urlretrieve
22
from rcsbapi.search import TextQuery
3+
from .enums import FileType
34

45

56
class PDB_DB:
@@ -50,7 +51,9 @@ def check_structure(self, uniprot_id: str) -> bool:
5051
return True
5152
return False
5253

53-
def make_url(self, uniprot_id: str, filetype: str = "pdb") -> str:
54+
def make_url(
55+
self, uniprot_id: str, filetype: FileType = FileType.pdb
56+
) -> str:
5457
"""
5558
Make the URL for the protein
5659
@@ -63,14 +66,15 @@ def make_url(self, uniprot_id: str, filetype: str = "pdb") -> str:
6366
6467
"""
6568

69+
filetype = FileType(filetype)
6670
uniprot_id = uniprot_id.upper()
67-
url = f"https://files.rcsb.org/download/{uniprot_id}.{filetype}"
71+
url = f"https://files.rcsb.org/download/{uniprot_id}.{filetype.name}"
6872
return url
6973

7074
def get_pdb(
7175
self,
7276
uniprot_id: str,
73-
filetype: str = "cif",
77+
filetype: FileType = FileType.cif,
7478
) -> tuple:
7579
"""
7680
Returns pdb/cif as strings, saves to file if requested
@@ -84,6 +88,7 @@ def get_pdb(
8488
8589
"""
8690

91+
filetype = FileType(filetype)
8792
if not self.results:
8893
self.results = [self.uniprot_id_to_pdb_id(uniprot_id)]
8994

@@ -97,9 +102,9 @@ def get_pdb(
97102
filedata = file.read()
98103
except Exception:
99104
if filetype == "pdb":
100-
filetype = "cif"
105+
filetype = FileType.cif
101106
else:
102-
filetype = "pdb"
107+
filetype = FileType.pdb
103108
url = self.make_url(pdb_id, filetype)
104109
filename, result = urlretrieve(url)
105110
with open(filename) as file:

profet/profet.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .pdb import PDB_DB
33
from .cache import PDBFileCache
44
from .cleaver import Cleaver
5+
from .enums import FileType
56
import os
67

78

@@ -54,7 +55,7 @@ def cache(self) -> PDBFileCache:
5455
def file_from_db(
5556
self,
5657
prot_id: str,
57-
filetype: str = "cif",
58+
filetype: FileType = FileType.cif,
5859
db: str = "pdb",
5960
) -> tuple:
6061
"""
@@ -69,14 +70,15 @@ def file_from_db(
6970
Tuple containing the filename and file from the database
7071
7172
"""
73+
filetype = FileType(filetype)
7274
return {"pdb": self.pdb.get_pdb, "alphafold": self.alpha.get_pdb}[db](
7375
prot_id, filetype=filetype
7476
)
7577

7678
def get_file(
7779
self,
7880
uniprot_id: str,
79-
filetype: str = "cif",
81+
filetype: FileType = FileType.cif,
8082
filesave: bool = False,
8183
db: str = "pdb",
8284
) -> tuple:
@@ -96,6 +98,7 @@ def get_file(
9698
2. File from the database, or None if it is not available in any database.
9799
98100
"""
101+
filetype = FileType(filetype)
99102

100103
# Get the PDB cache
101104
cache = PDBFileCache(directory=self.save_directory)
@@ -211,7 +214,7 @@ def remove(
211214
"""
212215
# Get the PDB cache
213216
cache = PDBFileCache(directory=self.save_directory)
214-
identifier, _, _ = self.pdb.get_pdb(uniprot_id, filetype="cif")
217+
identifier, _, _ = self.pdb.get_pdb(uniprot_id, filetype=FileType.cif)
215218
if uniprot_id in cache:
216219
filename = cache[uniprot_id]
217220
signal_list = self.Cleaver.signal_residuenumbers_requester(

0 commit comments

Comments
 (0)