7676Query the [AlphaFold](https://alphafold.com/) API for the latest structure of `uniprotXname`.
7777"""
7878function query_alphafold_latest (uniprotXname)
79- resp = HTTP. get (" https://alphafold.com/api/prediction/$uniprotXname " )
79+ resp = HTTP. get (" https://alphafold.com/api/prediction/$uniprotXname " ; status_exception = false )
8080 if resp. status == 200
8181 j = JSON3. read (String (resp. body))[1 ]
8282 return j[" pdbUrl" ]
111111
112112"""
113113 download_alphafolds(msa::AbstractMultipleSequenceAlignment; dirname=pwd())
114+ download_alphafolds(ids; dirname=pwd())
114115
115116Download all available [AlphaFold](https://alphafold.com/) structures for the sequences in `msa`.
116117Missing entries are silently skipped.
118+
119+ If a `AbstractMultipleSequenceAlignment` is provided, the downloaded PDB file is checked to ensure that
120+ the residues in the MSA sequence match those in the PDB file. If they do not match, the PDB file is removed.
117121"""
118122function download_alphafolds (msa:: AbstractMultipleSequenceAlignment ; dirname= pwd (), maxversion= nothing , kwargs... )
119123 maxversion === nothing || @warn " `download_alphafolds`: `maxversion` kwarg has no effect and is deprecated" maxlog= 1
@@ -133,6 +137,18 @@ function download_alphafolds(msa::AbstractMultipleSequenceAlignment; dirname=pwd
133137 end
134138end
135139
140+ function download_alphafolds (ids; dirname= pwd (), kwargs... )
141+ @showprogress 1 " Downloading AlphaFold files..." for uname in ids
142+ url = query_alphafold_latest (uname)
143+ url === nothing && continue
144+ fn = split (url, ' /' )[end ]
145+ path = joinpath (dirname, fn)
146+ if ! isfile (path)
147+ Downloads. download (url, path)
148+ end
149+ end
150+ end
151+
136152const pLDDTcolors = [ # see https://github.com/sokrypton/ColabFold?tab=readme-ov-file#faq
137153 RGB {N0f8} (0.051 , 0.341 , 0.827 ),
138154 RGB {N0f8} (0.416 , 0.796 , 0.945 ),
0 commit comments