Skip to content

Commit

Permalink
Add non-mutating SS assign method
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOresten committed Nov 25, 2023
1 parent 4fe3b15 commit e74fcf3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
18 changes: 15 additions & 3 deletions src/assign.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
export assign_secondary_structure!
export assign_secondary_structure!, assign_secondary_structure

import AssigningSecondaryStructure as ASS
import AssigningSecondaryStructure: assign_secondary_structure!, assign_secondary_structure

"""
assign_secondary_structure!(protein)
Uses a simplified version of DSSP to fill the secondary structure vector of each chain with Loop, Helix, and Strand.
"""
function assign_secondary_structure!(protein::Protein)
ss_num_vectors = ASS.assign_secondary_structure([chain.backbone.coords for chain in protein])
ss_num_vectors = assign_secondary_structure([chain.backbone.coords for chain in protein])
for (chain, ss_num_vector) in zip(protein, ss_num_vectors)
ssvec = SecondaryStructure.(ss_num_vector)
@assert length(chain.ssvec) == length(ssvec)
chain.ssvec .= ssvec
end
return protein
end

"""
assign_secondary_structure(protein)
Returns a new protein with secondary structure assigned.
"""
function assign_secondary_structure(protein::Protein)
new_protein = deepcopy(protein)
assign_secondary_structure!(new_protein)
return new_protein
end
16 changes: 12 additions & 4 deletions test/assign.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
@testset "assign.jl" begin

@testset "assign_secondary_structure!" begin
backbone = pdb_to_protein("data/1ASS.pdb")
@test has_missing_ss(backbone)
assign_secondary_structure!(backbone)
@test !has_missing_ss(backbone)
protein = pdb_to_protein("data/1ASS.pdb")
@test has_missing_ss(protein)
assign_secondary_structure!(protein)
@test !has_missing_ss(protein)
end

@testset "assign_secondary_structure" begin
protein = pdb_to_protein("data/1ASS.pdb")
@test has_missing_ss(protein)
new_protein = assign_secondary_structure(protein)
@test has_missing_ss(protein)
@test !has_missing_ss(new_protein)
end

end

0 comments on commit e74fcf3

Please sign in to comment.