Hello,
I have a csv file containing a few hundreds of PDB codes. I'm trying to figure out how to use Biopython to download these PDB files using each row of my csv file as input. I've seen that the PDBList module can be used to download PDB files by writing the PDB code on the download_pdb script but I was wondering if there is any way to tell PDBList to get those PDB codes from the csv file.
I got to this and don't know how to progress from here:
from Bio.PDB import PDBList
csv = pd.read_csv("filename.csv", header = None)
csv_df = pd.DataFrame(csv)
csv_df.items()
for row in csv_df.items():
pdbl.download_pdb_files(row)
Any ideas?
Thank you very much
Juan
1 answer
When you say CSV file, do you actually mean a single-column list of PDB ID numbers? If so, this will do the trick without BioPython:
cat filename.csv | xargs -i echo 'wget -q -o /dev/null ftp://ftp.ebi.ac.uk/pub/databases/msd/pdb_uncompressed/pdb{}.ent ; mv pdb{}.ent {}.pdb' > script.sh
source script.sh ; rm script.sh
Make sure you are in a directory where you want all these files to be downloaded. It may take a while and you will not see the progress. If you wish to see it, remove the -q -o /dev/null part from the first line.
Log in to answer this question.
Brilliant! Thanks a lot!