Skip to content

Commit 3cb55f4

Browse files
committed
rename PDB to PDBFormat etc.
1 parent fad4d4f commit 3cb55f4

13 files changed

Lines changed: 312 additions & 309 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ docs/build/
55
docs/site/
66
.DS_Store
77
benchmark/tune.json
8+
benchmark/results
89
Manifest.toml
910
*.swp

benchmark/benchmarks.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
# Benchmark suite for BioStructures
2-
# Run with something like:
2+
# Run with the following from the package base directory:
33
# using BioStructures
44
# using PkgBenchmark
55
# results = benchmarkpkg(".")
66
# export_markdown(out_file, results)
77

88
using BioStructures
99
using BenchmarkTools
10+
using BioAlignments
1011
import BioCore # Imported to avoid clash with BioGenerics distance
1112
using BioSequences
12-
import MMTF as MMTFPkg # Imported to avoid clash with MMTF name
13+
using Graphs
14+
import MMTF # Imported to avoid clash with writemmtf
15+
using MetaGraphs
1316
using Random
1417

1518
# Use files in BioFmtSpecimens
@@ -21,22 +24,22 @@ temp_filename, io = mktemp()
2124
close(io)
2225

2326
pdbids = ["1AKE", "1EN2", "1SSU"]
24-
formats = Dict("PDB"=> PDB, "mmCIF"=> MMCIF, "MMTF"=> MMTF)
25-
writefunctions = Dict("PDB"=> writepdb, "mmCIF"=> writemmcif, "MMTF"=> writemmtf)
27+
formats = Dict("PDB" => PDBFormat, "mmCIF" => MMCIFFormat, "MMTF" => MMTFFormat)
28+
writefunctions = Dict("PDB" => writepdb, "mmCIF" => writemmcif, "MMTF" => writemmtf)
2629

2730
const SUITE = BenchmarkGroup(
28-
[],
29-
"read" => BenchmarkGroup([], [f=> BenchmarkGroup() for f in keys(formats)]...),
30-
"write" => BenchmarkGroup([], [f=> BenchmarkGroup() for f in keys(formats)]...),
31-
"dict" => BenchmarkGroup(),
32-
"model" => BenchmarkGroup(),
33-
"collect"=> BenchmarkGroup(),
34-
"spatial"=> BenchmarkGroup(),
31+
[],
32+
"read" => BenchmarkGroup([], [f => BenchmarkGroup() for f in keys(formats)]...),
33+
"write" => BenchmarkGroup([], [f => BenchmarkGroup() for f in keys(formats)]...),
34+
"dict" => BenchmarkGroup(),
35+
"model" => BenchmarkGroup(),
36+
"collect" => BenchmarkGroup(),
37+
"spatial" => BenchmarkGroup(),
3538
)
3639

3740
struc = Dict{String, MolecularStructure}()
3841
for pdbid in pdbids
39-
struc[pdbid] = read(testfilepath("PDB", "$pdbid.pdb"), PDB)
42+
struc[pdbid] = read(testfilepath("PDB", "$pdbid.pdb"), PDBFormat)
4043
end
4144

4245
for pdbid in pdbids

docs/src/api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Package extensions are used in order to reduce the number of dependencies:
99
- To use `pairalign`, [`superimpose!`](@ref), [`rmsd`](@ref)/[`displacements`](@ref) with the `superimpose` option or [`Transformation`](@ref) on structural elements, call `using BioSequences, BioAlignments`.
1010
- To use `DataFrame`, call `using DataFrames`.
1111
- To use `MetaGraph`, call `using Graphs, MetaGraphs`.
12-
- To use [`MMTFDict`](@ref) or [`writemmtf`](@ref), call `import MMTF as MMTFPkg` (to avoid clashing with [`BioStructures.MMTF`](@ref)).
12+
- To use [`MMTFDict`](@ref) or [`writemmtf`](@ref), call `import MMTF`.
1313
- To use [`rundssp!`](@ref), [`rundssp`](@ref) or the `run_dssp` option for `read`/[`retrievepdb`](@ref), call `using DSSP_jll`.
1414
- To use [`runstride!`](@ref), [`runstride`](@ref) or the `run_stride` option for `read`/[`retrievepdb`](@ref), call `using STRIDE_jll`.
1515

docs/src/documentation.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ downloadpdb("1EN2")
2121
To parse a PDB file into a Structure-Model-Chain-Residue-Atom framework:
2222

2323
```julia-repl
24-
julia> struc = read("/path/to/pdb/file.pdb", PDB)
24+
julia> struc = read("/path/to/pdb/file.pdb", PDBFormat)
2525
MolecularStructure 1EN2.pdb with 1 models, 1 chains (A), 85 residues, 754 atoms
2626
```
2727

28-
mmCIF files can be read into the same data structure with `read("/path/to/cif/file.cif", MMCIF)`.
28+
mmCIF files can be read into the same data structure with `read("/path/to/cif/file.cif", MMCIFFormat)`.
2929
The keyword argument `gzip`, default `false`, determines if the file is gzipped.
3030
If you want to read an mmCIF file into a dictionary to query yourself (e.g. to access metadata fields), use [`MMCIFDict`](@ref):
3131

@@ -41,7 +41,7 @@ julia> mmcif_dict["_entity_src_nat.common_name"]
4141
A [`MMCIFDict`](@ref) can be accessed in similar ways to a standard dictionary, and if necessary the underlying dictionary of [`MMCIFDict`](@ref) `d` can be accessed with `d.dict`.
4242
Note that the values of the dictionary are always an `Array{String,1}`, even if only one value was read in or the data is numerical.
4343

44-
MMTF files can be read into the same data structure with `read("/path/to/mmtf/file.mmtf", MMTF)` once you have imported MMTF.jl with `import MMTF as MMTFPkg`.
44+
MMTF files can be read into the same data structure with `read("/path/to/mmtf/file.mmtf", MMTFFormat)` once you have imported MMTF.jl.
4545
The keyword argument `gzip`, default `false`, determines if the file is gzipped.
4646
In a similar manner to mmCIF dictionaries, a MMTF file can be read into a dictionary with [`MMTFDict`](@ref).
4747
The values of the dictionary are a variety of types depending on the [MMTF specification](https://github.com/rcsb/mmtf/blob/master/spec.md).
@@ -545,10 +545,10 @@ The secondary structure code of a residue or atom can be accessed after assignin
545545
To assign secondary structure when reading the structure:
546546
```julia
547547
# Assign secondary structure using DSSP
548-
read("/path/to/pdb/file.pdb", PDB, run_dssp=true)
548+
read("/path/to/pdb/file.pdb", PDBFormat, run_dssp=true)
549549

550550
# Assign secondary structure using STRIDE
551-
read("/path/to/pdb/file.pdb", PDB, run_stride=true)
551+
read("/path/to/pdb/file.pdb", PDBFormat, run_stride=true)
552552
```
553553
[`rundssp!`](@ref), [`runstride!`](@ref), [`rundssp`](@ref) and [`runstride`](@ref) can also be used to assign secondary structure to a [`MolecularStructure`](@ref) or [`Model`](@ref):
554554
```julia
@@ -593,10 +593,10 @@ To download a PDB file in PDB, XML, mmCIF or MMTF format use the `format` argume
593593

594594
```julia
595595
# To get mmCIF
596-
downloadpdb("1ALW", dir="path/to/pdb/directory", format=MMCIF)
596+
downloadpdb("1ALW", dir="path/to/pdb/directory", format=MMCIFFormat)
597597

598598
# To get XML
599-
downloadpdb("1ALW", dir="path/to/pdb/directory", format=PDBXML)
599+
downloadpdb("1ALW", dir="path/to/pdb/directory", format=PDBXMLFormat)
600600
```
601601

602602
To apply a function to a downloaded file and delete the file afterwards:
@@ -609,7 +609,7 @@ Or, using Julia's `do` syntax:
609609

610610
```julia
611611
downloadpdb("1ALW") do fp
612-
s = read(fp, PDB)
612+
s = read(fp, PDBFormat)
613613
# Do something
614614
end
615615
```
@@ -622,11 +622,11 @@ In this case download the mmCIF file or MMTF file instead.
622622
To parse an existing PDB file into a Structure-Model-Chain-Residue-Atom framework:
623623

624624
```julia-repl
625-
julia> struc = read("/path/to/pdb/file.pdb", PDB)
625+
julia> struc = read("/path/to/pdb/file.pdb", PDBFormat)
626626
MolecularStructure 1EN2.pdb with 1 models, 1 chains (A), 85 residues, 754 atoms
627627
```
628628

629-
Read a mmCIF/MMTF file instead by replacing [`PDB`](@ref) with [`MMCIF`](@ref)/[`MMTF`](@ref).
629+
Read a mmCIF/MMTF file instead by replacing [`PDBFormat`](@ref) with [`MMCIFFormat`](@ref)/[`MMTFFormat`](@ref).
630630
Various options can be set through optional keyword arguments when parsing PDB/mmCIF/MMTF files:
631631

632632
| Keyword Argument | Description |
@@ -712,7 +712,7 @@ A [`MMCIFDict`](@ref) can also be written using [`writemmcif`](@ref):
712712
writemmcif("1EN2_out.dic", mmcif_dict)
713713
```
714714

715-
To write out a MMTF file, call `import MMTF as MMTFPkg` and use the [`writemmtf`](@ref) function with any element type or a [`MMTFDict`](@ref) as an argument.
715+
To write out a MMTF file, import MMTF.jl and use the [`writemmtf`](@ref) function with any element type or a [`MMTFDict`](@ref) as an argument.
716716
The `gzip` keyword argument, default `false`, determines whether to gzip the written file.
717717

718718
Unlike for the collection functions, `expand_disordered` is set to `true` when writing files as it is usually desirable to retain all entities.
@@ -748,15 +748,15 @@ l = pdbentrylist()
748748
To download the entire RCSB PDB database in your preferred file format:
749749

750750
```julia
751-
downloadentirepdb(dir="path/to/pdb/directory", format=MMTF)
751+
downloadentirepdb(dir="path/to/pdb/directory", format=MMTFFormat)
752752
```
753753

754754
This operation takes a lot of disk space and time to complete, depending on internet connection.
755755

756756
To update your local PDB directory based on the weekly status list of new, modified and obsolete PDB files from the RCSB server:
757757

758758
```julia
759-
updatelocalpdb(dir="path/to/pdb/directory", format=MMTF)
759+
updatelocalpdb(dir="path/to/pdb/directory", format=MMTFFormat)
760760
```
761761

762762
Obsolete PDB files are stored in the auto-generated `obsolete` directory inside the specified local PDB directory.
@@ -1440,7 +1440,7 @@ You can view BioStructures data types:
14401440

14411441
```julia
14421442
struc = retrievepdb("1AKE")
1443-
viewstruc(struc['A'], surface=Surface(Dict("colorscheme"=> "greenCarbon")))
1443+
viewstruc(struc['A'], surface=Surface(Dict("colorscheme" => "greenCarbon")))
14441444
```
14451445

14461446
```@raw html

docs/src/examples.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Here we give further examples, showing what you can do with the package.
99
using BioStructures
1010
using Statistics
1111

12-
struc = read("1AKE.pdb", PDB)
12+
struc = read("1AKE.pdb", PDBFormat)
1313
res_list = collectresidues(struc, standardselector)
1414

1515
function sidechainheavyselector(a::AbstractAtom)
@@ -86,7 +86,7 @@ scatter(
8686

8787
```julia
8888
downloadpdb("1SSU")
89-
struc_nmr = read("1SSU.pdb", PDB)
89+
struc_nmr = read("1SSU.pdb", PDBFormat)
9090
rmsd(struc_nmr[5], struc_nmr[10], superimpose=false, rmsdatoms=heavyatomselector)
9191
displacements(struc_nmr[5], struc_nmr[10], superimpose=false, rmsdatoms=heavyatomselector)
9292
```
@@ -96,8 +96,8 @@ displacements(struc_nmr[5], struc_nmr[10], superimpose=false, rmsdatoms=heavyato
9696
```julia
9797
l = pdbentrylist()
9898
for p in l
99-
downloadpdb(p, format=MMCIF) do fp
100-
s = read(fp, MMCIF)
99+
downloadpdb(p, format=MMCIFFormat) do fp
100+
s = read(fp, MMCIFFormat)
101101
nres = countresidues(s, standardselector)
102102
if nres > 0
103103
frac = countresidues(s, standardselector, x -> resname(x) == "CYS") / nres

ext/BioStructuresMMTFExt.jl

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,58 +2,58 @@ module BioStructuresMMTFExt
22

33
using BioStructures
44
using BioSymbols
5-
import MMTF as MMTFPkg # Imported to avoid clash with MMTF name
5+
import MMTF # Imported to avoid clash with writemmtf
66

77
# Create an empty MMTF dictionary
88
# Matches the decoded form of a MMTF file using MMTF.jl
99
# Encoding and decoding this Dict gives an identical Dict
1010
BioStructures.MMTFDict() = MMTFDict(Dict{String, Any}(
11-
"altLocList" => Char[],
12-
"atomIdList" => Int32[],
13-
"bFactorList" => Float32[],
14-
"bioAssemblyList" => Any[],
15-
"bondAtomList" => Int32[],
16-
"bondOrderList" => Int8[],
17-
"chainIdList" => String[],
18-
"chainNameList" => String[],
19-
"chainsPerModel" => Any[],
20-
"depositionDate" => "",
21-
"entityList" => Any[],
22-
"experimentalMethods"=> Any[],
23-
"groupIdList" => Int32[],
24-
"groupList" => Any[],
25-
"groupsPerChain" => Any[],
26-
"groupTypeList" => Int32[],
27-
"insCodeList" => Char[],
28-
"mmtfProducer" => "",
29-
"mmtfVersion" => "",
30-
"ncsOperatorList" => Any[],
31-
"numAtoms" => 0,
32-
"numBonds" => 0,
33-
"numChains" => 0,
34-
"numGroups" => 0,
35-
"numModels" => 0,
36-
"occupancyList" => Float32[],
37-
"releaseDate" => "",
38-
"resolution" => 0.0,
39-
"rFree" => "",
40-
"rWork" => "",
41-
"secStructList" => Int8[],
42-
"sequenceIndexList" => Int32[],
43-
"spaceGroup" => "",
44-
"structureId" => "",
45-
"title" => "",
46-
"unitCell" => Any[],
47-
"xCoordList" => Float32[],
48-
"yCoordList" => Float32[],
49-
"zCoordList" => Float32[],
11+
"altLocList" => Char[],
12+
"atomIdList" => Int32[],
13+
"bFactorList" => Float32[],
14+
"bioAssemblyList" => Any[],
15+
"bondAtomList" => Int32[],
16+
"bondOrderList" => Int8[],
17+
"chainIdList" => String[],
18+
"chainNameList" => String[],
19+
"chainsPerModel" => Any[],
20+
"depositionDate" => "",
21+
"entityList" => Any[],
22+
"experimentalMethods" => Any[],
23+
"groupIdList" => Int32[],
24+
"groupList" => Any[],
25+
"groupsPerChain" => Any[],
26+
"groupTypeList" => Int32[],
27+
"insCodeList" => Char[],
28+
"mmtfProducer" => "",
29+
"mmtfVersion" => "",
30+
"ncsOperatorList" => Any[],
31+
"numAtoms" => 0,
32+
"numBonds" => 0,
33+
"numChains" => 0,
34+
"numGroups" => 0,
35+
"numModels" => 0,
36+
"occupancyList" => Float32[],
37+
"releaseDate" => "",
38+
"resolution" => 0.0,
39+
"rFree" => "",
40+
"rWork" => "",
41+
"secStructList" => Int8[],
42+
"sequenceIndexList" => Int32[],
43+
"spaceGroup" => "",
44+
"structureId" => "",
45+
"title" => "",
46+
"unitCell" => Any[],
47+
"xCoordList" => Float32[],
48+
"yCoordList" => Float32[],
49+
"zCoordList" => Float32[],
5050
))
5151

5252
function BioStructures.MMTFDict(filepath::AbstractString; gzip::Bool=false)
53-
return MMTFDict(MMTFPkg.parsemmtf(filepath; gzip=gzip))
53+
return MMTFDict(MMTF.parsemmtf(filepath; gzip=gzip))
5454
end
5555

56-
BioStructures.MMTFDict(io::IO; gzip::Bool=false) = MMTFDict(MMTFPkg.parsemmtf(io; gzip=gzip))
56+
BioStructures.MMTFDict(io::IO; gzip::Bool=false) = MMTFDict(MMTF.parsemmtf(io; gzip=gzip))
5757

5858
Base.getindex(mmtf_dict::MMTFDict, field::AbstractString) = mmtf_dict.dict[field]
5959

@@ -77,15 +77,15 @@ function Base.show(io::IO, mmtf_dict::MMTFDict)
7777
end
7878

7979
function Base.read(input::IO,
80-
::Type{MMTF};
80+
::Type{MMTFFormat};
8181
structure_name::AbstractString="",
8282
remove_disorder::Bool=false,
8383
read_std_atoms::Bool=true,
8484
read_het_atoms::Bool=true,
8585
run_dssp::Bool=false,
8686
run_stride::Bool=false,
8787
gzip::Bool=false)
88-
d = MMTFDict(MMTFPkg.parsemmtf(input; gzip=gzip))
88+
d = MMTFDict(MMTF.parsemmtf(input; gzip=gzip))
8989
return MolecularStructure(
9090
d;
9191
structure_name=structure_name,
@@ -188,7 +188,7 @@ end
188188
function BioStructures.writemmtf(output::Union{AbstractString, IO},
189189
d::MMTFDict;
190190
gzip::Bool=false)
191-
MMTFPkg.writemmtf(d.dict, output; gzip=gzip)
191+
MMTF.writemmtf(d.dict, output; gzip=gzip)
192192
return
193193
end
194194

@@ -248,10 +248,10 @@ function BioStructures.writemmtf(output::Union{AbstractString, IO},
248248
# Checking for similar entities is non-trivial so we treat
249249
# each molecule as a separate entity
250250
push!(d["entityList"], Dict{Any, Any}(
251-
"chainIndexList"=> Any[length(d["chainIdList"]) - 1],
252-
"description" => "",
253-
"sequence" => "", # This is changed later
254-
"type" => ishetero(res) ? "non-polymer" : "polymer"
251+
"chainIndexList" => Any[length(d["chainIdList"]) - 1],
252+
"description" => "",
253+
"sequence" => "", # This is changed later
254+
"type" => ishetero(res) ? "non-polymer" : "polymer",
255255
))
256256
end
257257
if !ishetero(res)
@@ -282,15 +282,15 @@ function BioStructures.writemmtf(output::Union{AbstractString, IO},
282282

283283
if group_i == 0
284284
push!(d["groupList"], Dict{Any, Any}(
285-
"groupName" => resname(res),
286-
"bondAtomList" => Any[],
287-
"elementList" => Any[element(at) for at in ats_res],
285+
"groupName" => resname(res),
286+
"bondAtomList" => Any[],
287+
"elementList" => Any[element(at) for at in ats_res],
288288
# MMTF specifies missing charges as zero
289-
"formalChargeList"=> Any[charge(at) == "" ? 0 : parse(Int64, charge(at)) for at in ats_res],
290-
"singleLetterCode"=> "",
291-
"chemCompType" => "",
292-
"atomNameList" => Any[at_names...],
293-
"bondOrderList" => Any[]
289+
"formalChargeList" => Any[charge(at) == "" ? 0 : parse(Int64, charge(at)) for at in ats_res],
290+
"singleLetterCode" => "",
291+
"chemCompType" => "",
292+
"atomNameList" => Any[at_names...],
293+
"bondOrderList" => Any[],
294294
))
295295
end
296296

src/BioStructures.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ include("spatial.jl")
4141
ATOM 8 CE MET A 1 -3.296 14.391 24.798 1.00 54.68 C
4242
END
4343
""")
44-
struc = read(path, PDB)
44+
struc = read(path, PDBFormat)
4545
show(devnull, struc)
4646
collectatoms(struc, sel"serial < 5")
4747
end

0 commit comments

Comments
 (0)