Skip to content

Commit

Permalink
Remove renumber, random fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOresten committed Nov 3, 2024
1 parent 7d76d43 commit dfe2947
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 225 deletions.
10 changes: 2 additions & 8 deletions src/ProteinChains.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,13 @@ using Backboner

using Compat: @compat

include("ideal.jl")
export BackboneGeometry
export IdealResidue, STANDARD_RESIDUE
export append_residue, prepend_residue

include("atom.jl")
export Atom
@compat public (atom_name, atom_number, atom_coords, atom_symbol)
@compat public (atom_name, atom_number, atom_coords, atom_symbol, atom_mass)

include("properties.jl")
export StandardProperty, IndexableProperty
export AbstractProperty, StandardProperty, IndexableProperty
export setproperties, addproperties, removeproperties
@compat public AbstractProperty

include("chain.jl")
export ProteinChain
Expand Down
10 changes: 5 additions & 5 deletions src/chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@ end

Base.length(chain::ProteinChain) = length(chain.atoms)

Base.getproperty(chain::ProteinChain, name::Symbol) =
name in fieldnames(ProteinChain) ? getfield(chain, name) : unpack(getfield(getfield(chain, :properties), name))

Base.propertynames(chain::ProteinChain, private::Bool=false) = (setdiff(fieldnames(ProteinChain), private ? () : (:properties,))..., propertynames(chain.properties)...)

function Base.getindex(chain::ProteinChain, i::Union{AbstractVector,Colon})
properties = map(p -> p[i], chain.properties)
ProteinChain(chain.id, chain.atoms[i], chain.sequence[i], chain.numbering[i], properties)
end

Base.getproperty(chain::ProteinChain, name::Symbol) =
name in fieldnames(ProteinChain) ? getfield(chain, name) : unpack(getfield(getfield(chain, :properties), name))

Base.propertynames(chain::ProteinChain, private::Bool=false) = (setdiff(fieldnames(ProteinChain), private ? () : (:properties,))..., propertynames(chain.properties)...)

setproperties(chain::ProteinChain, ps::NamedTuple) =
ProteinChain(chain.id, chain.atoms, chain.sequence, chain.ins_codes, chain.numbering, setproperties(chain.properties, ps))

Expand Down
110 changes: 0 additions & 110 deletions src/ideal.jl

This file was deleted.

1 change: 0 additions & 1 deletion src/io/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const pdbextension_to_format = Dict(ext => format for (format, ext) in BioStruct

get_format(path::AbstractString) = get(pdbextension_to_format, lowercase(last(splitext(path))[2:end]), PDBFormat)

include("renumber.jl")
include("read.jl")
include("write.jl")
include("download.jl")
Expand Down
49 changes: 0 additions & 49 deletions src/io/renumber.jl

This file was deleted.

8 changes: 8 additions & 0 deletions src/structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,19 @@ function map_atoms!(f::Function, structure::ProteinStructure, args...)
return structure
end

Base.getproperty(structure::ProteinStructure, name::Symbol) =
name in fieldnames(ProteinStructure) ? getfield(structure, name) : unpack(getfield(getfield(structure, :properties), name))

Base.propertynames(structure::ProteinStructure, private::Bool=false) = (setdiff(fieldnames(ProteinStructure), private ? () : (:properties,))..., propertynames(structure.properties)...)

setproperties(structure::ProteinStructure, properties::NamedTuple) =
ProteinStructure(structure.name, structure.atoms, structure.chains, setproperties(structure.properties, properties))

addproperties(structure::ProteinStructure, properties::NamedTuple) =
setproperties(structure, addproperties(structure.properties, properties))

addproperties(structure::ProteinStructure; properties...) =
setproperties(structure, addproperties(structure.properties, NamedTuple(properties)))

removeproperties(structure::ProteinStructure, names::Symbol...) =
setproperties(structure, removeproperties(structure.properties, names...))
52 changes: 0 additions & 52 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,58 +90,6 @@ using Test
end
end

# See https://proteopedia.org/wiki/index.php/Unusual_sequence_numbering
@testset "Unusual numbering" begin

@testset "Arbitrary Numbering" begin
structure = ProteinChains.renumber(pdb"1BSZ", mmcifdict"1BSZ")
@test !allequal(chain -> chain.numbering, structure)
@test allequal(chain -> chain.renumbering, structure)
end

@testset "N-Terminal Residues Missing Coordinates" begin
structure = ProteinChains.renumber(pdb"1D66", mmcifdict"1D66")
chain = structure["A"]
@test chain.numbering[begin] == 8
@test chain.renumbering[begin] == 8
end

@testset "Starts With Zero Or Negative Numbers" begin
structure = ProteinChains.renumber(pdb"1BXW", mmcifdict"1BXW")
chain = structure["A"]
@test chain.numbering[begin] == 0
@test chain.renumbering[begin] == 1

structure = ProteinChains.renumber(pdb"1D5T", mmcifdict"1D5T")
chain = structure["A"]
@test chain.numbering[begin] == -2
@test chain.renumbering[begin] == 1
end

@testset "Insertion Codes" begin
structure = ProteinChains.renumber(pdb"1IGY", mmcifdict"1IGY")
chain = structure["B"]
@test count(==(82), chain.numbering) == 4
@test allunique(chain.renumbering)
@test Set(collect(chain.ins_codes)) == Set([' ', 'A', 'B', 'C'])
end

@testset "Skipping Sequence Numbers" begin
structure = ProteinChains.renumber(pdb"2ACE", mmcifdict"2ACE")
chain = structure["A"]
@test any(!isone, chain.numbering[begin+1:end] - chain.numbering[begin:end-1])
@test chain.numbering == chain.renumbering
end

@testset "Not Monotonic" begin
structure = ProteinChains.renumber(pdb"1NSA", mmcifdict"1NSA")
chain = structure["A"]
@test issorted(chain.numbering) # BioStructures sorts automatically with `fixlists!`, so residues are in wrong order
@test !issorted(chain.renumbering) # the renumbering is not monotonic. it would be if BioStructures didn't sort.
end

end

end

@testset "store" begin
Expand Down

0 comments on commit dfe2947

Please sign in to comment.