Re: [ccp4bb] Downloading individual chains from the PDB

2023-09-08 Thread Whitley, Matthew (NIH/NCI) [C]
Thank you to everyone who responded to my post.  I think the responses were 
clear, and I’ve learned several new tricks for accessing specific PDB data.

Matthew



To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1

This message was issued to members of www.jiscmail.ac.uk/CCP4BB, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [ccp4bb] Downloading individual chains from the PDB

2023-09-07 Thread Gary Thompson
I stand corrected and have learnt a new trick, thanks Jose!

Note jose’s reply has a typo it is 
https://models.rcsb.org<https://models.rcsb.org/> not 
https://modes.rcsb.org<https://modes.rcsb.org/>

loading the page https://models.rcsb.org<https://models.rcsb.org/> on its own 
gives a nice rather nice listing of the api…

Regards
Gary


Dr Gary S Thompson
NMR Facility Manager
CCPN CoI & Working Group Member

Wellcome Trust Biomolecular NMR Facility
School of Biosciences, Faculty of Natural Sciences
University of Kent, Canterbury,  Kent,
England,  CT2 7NZ


tel: 01227 82 7117
e-mail: g.s.thomp...@kent.ac.uk<mailto:g.s.thomp...@kent.ac.uk>
orchid: 
orcid.org/-0001-9399-7636<https://urldefense.com/v3/__http:/orcid.org/-0001-9399-7636__;!!JFdNOqOXpB6UZW0!5pL_seJsFx0GRaDgwaLL0h3tmVktbehHKv07ZEZEcqZMKbC_s464UgFam-zmCFabTW0x$>



From: CCP4 bulletin board  on behalf of Jose Duarte 
<ac8ce2e7d24d-dmarc-requ...@jiscmail.ac.uk>
Date: Thursday, 7 September 2023 at 18:03
To: CCP4BB@JISCMAIL.AC.UK 
Subject: Re: [ccp4bb] Downloading individual chains from the PDB
CAUTION: This email originated from outside of the organisation. Do not click 
links or open attachments unless you recognise the sender and know the content 
is safe.

Gary pointed me to a typo in the API reference link (thanks!). This is the 
correct one: https://models.rcsb.org<https://models.rcsb.org/>

On Thu, 7 Sept 2023 at 09:34, Jose Duarte 
mailto:jose.dua...@rcsb.org>> wrote:
The ModelServer API is your friend. See the APIs help page at 
https://www.rcsb.org/docs/programmatic-access/web-services-overview and the 
full ModelServer API reference at 
https://modes.rcsb.org<https://modes.rcsb.org/>

An example that retrieves chain A of 2trx (in CIF format): 
https://models.rcsb.org/v1/2trx/atoms?label_asym_id=A=cif_all_categories=false=false

I'll also take this opportunity to advertise the upcoming RCSB PDB APIs crash 
course: https://iqb.rutgers.edu/node/279 . Though the course will mostly deal 
with other APIs (Data and Search).

Hope this helps

Jose


On Thu, 7 Sept 2023 at 09:17, Whitley, Matthew (NIH/NCI) [C] 
<a8ed4e9d4a1a-dmarc-requ...@jiscmail.ac.uk<mailto:a8ed4e9d4a1a-dmarc-requ...@jiscmail.ac.uk>>
 wrote:
Hello all,

I have a script I use from time to time to batch download multiple PDB files 
using curl.

I have certain use cases in which I only need a specific chain from a PDB file 
that contains multiple chains.  At present, I download the complete PDB file 
and then use pdbtools to pull out the specific chain I want.

Does anyone know a way to batch download specific chains from the PDB?   I 
reviewed the “File Download Services” page at the RCSB PDB, but I didn’t find 
anything about downloading specific chains, so I don’t know if this 
functionality exists.

Thanks for your suggestions.
Matthew




To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1



To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1



To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1

This message was issued to members of www.jiscmail.ac.uk/CCP4BB, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [ccp4bb] Downloading individual chains from the PDB

2023-09-07 Thread Jose Duarte
Gary pointed me to a typo in the API reference link (thanks!). This is the
correct one: https://models.rcsb.org

On Thu, 7 Sept 2023 at 09:34, Jose Duarte  wrote:

> The ModelServer API is your friend. See the APIs help page at
> https://www.rcsb.org/docs/programmatic-access/web-services-overview and
> the full ModelServer API reference at https://modes.rcsb.org
>
> An example that retrieves chain A of 2trx (in CIF format):
> https://models.rcsb.org/v1/2trx/atoms?label_asym_id=A=cif_all_categories=false=false
>
> I'll also take this opportunity to advertise the upcoming RCSB PDB APIs
> crash course: https://iqb.rutgers.edu/node/279 . Though the course will
> mostly deal with other APIs (Data and Search).
>
> Hope this helps
>
> Jose
>
>
> On Thu, 7 Sept 2023 at 09:17, Whitley, Matthew (NIH/NCI) [C] <
> a8ed4e9d4a1a-dmarc-requ...@jiscmail.ac.uk> wrote:
>
>> Hello all,
>>
>>
>>
>> I have a script I use from time to time to batch download multiple PDB
>> files using curl.
>>
>>
>>
>> I have certain use cases in which I only need a specific chain from a PDB
>> file that contains multiple chains.  At present, I download the complete
>> PDB file and then use pdbtools to pull out the specific chain I want.
>>
>>
>>
>> Does anyone know a way to batch download *specific chains* from the PDB?
>>   I reviewed the “File Download Services” page at the RCSB PDB, but I
>> didn’t find anything about downloading specific chains, so I don’t know if
>> this functionality exists.
>>
>>
>>
>> Thanks for your suggestions.
>>
>> Matthew
>>
>>
>>
>> --
>>
>> To unsubscribe from the CCP4BB list, click the following link:
>> https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1
>>
>



To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1

This message was issued to members of www.jiscmail.ac.uk/CCP4BB, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [ccp4bb] Downloading individual chains from the PDB

2023-09-07 Thread Georg Mlynek

Hi, here a script you can use in a jupyter notebook or colab:

!pip install biopython
importos
importrequests
fromBio importPDB
importshutil
fromgoogle.colab importfiles
# Create the folder if it doesn't exist
ifnotos.path.exists('pdb_files'):
    os.makedirs('pdb_files')
# Function to download PDB file
defdownload_pdb(pdb_id, save_path):
    url = f"https://files.rcsb.org/download/{pdb_id}.pdb;
    response = requests.get(url)
ifresponse.status_code == 200:
withopen(os.path.join(save_path, f"{pdb_id}.pdb"), 'w') asf:
            f.write(response.text)
else:
print(f"Failed to download {pdb_id}")
# Function to extract a specific chain from a PDB file and save it
defsave_chain_from_pdb(pdb_id, chain_id, save_path):
    parser = PDB.PDBParser(QUIET=True)
    structure = parser.get_structure(pdb_id, os.path.join(save_path, 
f"{pdb_id}.pdb"))

    io = PDB.PDBIO()
    io.set_structure(structure)
# Save only the specified chain
    io.save(os.path.join(save_path, f"{pdb_id}_{chain_id}.pdb"), 
select=ChainSelector(chain_id))

# Class to select a specific chain
classChainSelector(PDB.Select):
def__init__(self, chain_id):
self.chain_id = chain_id
defaccept_chain(self, chain):
returnchain.id == self.chain_id
# Define the folder where you want to save the files
# Make sure to run this Python script with sufficient permissions to 
write to this directory.

save_path = os.path.expanduser('/content/pdb_files')
# List of PDB IDs and the chain IDs you are interested in
pdb_chain_list = [
    {"pdb": "1TUP", "chain": "A"},
    {"pdb": "2HRK", "chain": "B"},
    {"pdb": "1LCD", "chain": "A"}
]
# Download PDB files and then extract the specific chain
foritem inpdb_chain_list:
    pdb_id = item["pdb"]
    chain_id = item["chain"]
print(f"Processing {pdb_id}chain {chain_id}")
# Download PDB file
    download_pdb(pdb_id, save_path)
# Extract and save the chain
    save_chain_from_pdb(pdb_id, chain_id, save_path)
# Create a Zip file (archive)
shutil.make_archive('pdb_files', 'zip', 'pdb_files')
# Download Zip file
files.download('pdb_files.zip')

Br, Georg.


Am 07.09.2023 um 18:17 schrieb Whitley, Matthew (NIH/NCI) [C]:


Hello all,

I have a script I use from time to time to batch download multiple PDB 
files using curl.


I have certain use cases in which I only need a specific chain from a 
PDB file that contains multiple chains.  At present, I download the 
complete PDB file and then use pdbtools to pull out the specific chain 
I want.


Does anyone know a way to batch download /specific chains/ from the 
PDB?   I reviewed the “File Download Services” page at the RCSB PDB, 
but I didn’t find anything about downloading specific chains, so I 
don’t know if this functionality exists.


Thanks for your suggestions.

Matthew




To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1 







To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1

This message was issued to members of www.jiscmail.ac.uk/CCP4BB, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/

Re: [ccp4bb] Downloading individual chains from the PDB

2023-09-07 Thread Jose Duarte
The ModelServer API is your friend. See the APIs help page at
https://www.rcsb.org/docs/programmatic-access/web-services-overview and the
full ModelServer API reference at https://modes.rcsb.org

An example that retrieves chain A of 2trx (in CIF format):
https://models.rcsb.org/v1/2trx/atoms?label_asym_id=A=cif_all_categories=false=false

I'll also take this opportunity to advertise the upcoming RCSB PDB APIs
crash course: https://iqb.rutgers.edu/node/279 . Though the course will
mostly deal with other APIs (Data and Search).

Hope this helps

Jose


On Thu, 7 Sept 2023 at 09:17, Whitley, Matthew (NIH/NCI) [C] <
a8ed4e9d4a1a-dmarc-requ...@jiscmail.ac.uk> wrote:

> Hello all,
>
>
>
> I have a script I use from time to time to batch download multiple PDB
> files using curl.
>
>
>
> I have certain use cases in which I only need a specific chain from a PDB
> file that contains multiple chains.  At present, I download the complete
> PDB file and then use pdbtools to pull out the specific chain I want.
>
>
>
> Does anyone know a way to batch download *specific chains* from the PDB?
>   I reviewed the “File Download Services” page at the RCSB PDB, but I
> didn’t find anything about downloading specific chains, so I don’t know if
> this functionality exists.
>
>
>
> Thanks for your suggestions.
>
> Matthew
>
>
>
> --
>
> To unsubscribe from the CCP4BB list, click the following link:
> https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1
>



To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1

This message was issued to members of www.jiscmail.ac.uk/CCP4BB, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [ccp4bb] Downloading individual chains from the PDB

2023-09-07 Thread Gary Thompson
The PDB will only provide you with complete deposited files. You can’t download 
individual chains. The only way to do it is as you are doing, grab the 
deposited file and then parse it to get the chains….

Regards
Gary

Dr Gary S Thompson
NMR Facility Manager
CCPN CoI & Working Group Member

Wellcome Trust Biomolecular NMR Facility
School of Biosciences, Faculty of Natural Sciences
University of Kent, Canterbury,  Kent,
England,  CT2 7NZ


tel: 01227 82 7117
e-mail: g.s.thomp...@kent.ac.uk
orchid: 
orcid.org/-0001-9399-7636



From: CCP4 bulletin board  on behalf of Whitley, Matthew 
(NIH/NCI) [C] 
Date: Thursday, 7 September 2023 at 17:17
To: CCP4BB@JISCMAIL.AC.UK 
Subject: [ccp4bb] Downloading individual chains from the PDB
CAUTION: This email originated from outside of the organisation. Do not click 
links or open attachments unless you recognise the sender and know the content 
is safe.

Hello all,

I have a script I use from time to time to batch download multiple PDB files 
using curl.

I have certain use cases in which I only need a specific chain from a PDB file 
that contains multiple chains.  At present, I download the complete PDB file 
and then use pdbtools to pull out the specific chain I want.

Does anyone know a way to batch download specific chains from the PDB?   I 
reviewed the “File Download Services” page at the RCSB PDB, but I didn’t find 
anything about downloading specific chains, so I don’t know if this 
functionality exists.

Thanks for your suggestions.
Matthew




To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1



To unsubscribe from the CCP4BB list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=CCP4BB=1

This message was issued to members of www.jiscmail.ac.uk/CCP4BB, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/