Skip to content

Commit

Permalink
Rename atom coords functions
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonOresten committed Dec 28, 2023
1 parent ab24913 commit 2fac583
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
14 changes: 7 additions & 7 deletions src/protein/chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ Base.show(io::IO, chain::Chain) = print(io, summary(chain))
@inline Base.getindex(protein::AbstractVector{Chain}, id::AbstractString) = protein[findfirst(chain -> chain.id == id, protein)]
@inline Base.getindex(protein::AbstractVector{Chain}, id::Symbol) = protein[String(id)]

export nitrogens, alphacarbons, carbonyls
export nitrogen_coords, alphacarbon_coords, carbonyl_coords

nitrogens(backbone::Backbone) = backbone[1:3:end]
alphacarbons(backbone::Backbone) = backbone[2:3:end]
carbonyls(backbone::Backbone) = backbone[3:3:end]
nitrogen_coords(backbone::Backbone) = (@view backbone[1:3:end]).coords
alphacarbon_coords(backbone::Backbone) = (@view backbone[2:3:end]).coords
carbonyl_coords(backbone::Backbone) = (@view backbone[3:3:end]).coords

nitrogens(chain::Chain) = nitrogens(chain.backbone)
alphacarbons(chain::Chain) = alphacarbons(chain.backbone)
carbonyls(chain::Chain) = carbonyls(chain.backbone)
nitrogen_coords(chain::Chain) = nitrogen_coords(chain.backbone)
alphacarbon_coords(chain::Chain) = alphacarbon_coords(chain.backbone)
carbonyl_coords(chain::Chain) = carbonyl_coords(chain.backbone)
# oxygen_coords function in src/protein/oxygen.jl

export nitrogen_alphacarbon_distances, alphacarbon_carbonyl_distances, carbonyl_nitrogen_distances
Expand Down
10 changes: 4 additions & 6 deletions src/protein/oxygen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ function get_last_oxygen(
return O_pos
end

function oxygen_coords(
backbone::Backbone,
)
function oxygen_coords(backbone::Backbone)
T = eltype(eltype(backbone))
L = length(backbone) ÷ 3

CAs = alphacarbons(backbone)
Cs = carbonyls(backbone)
next_Ns = @view nitrogens(backbone)[2:end]
CAs = eachcol(alphacarbon_coords(backbone))
Cs = eachcol(carbonyl_coords(backbone))
next_Ns = eachcol(@view nitrogen_coords(backbone)[:, 2:end])
oxygen_coords = zeros(T, 3, L)
for (i, (CA, C, next_N)) in enumerate(zip(CAs, Cs, next_Ns))
oxygen_coords[:, i] = estimate_oxygen_position(CA, C, next_N)
Expand Down

0 comments on commit 2fac583

Please sign in to comment.