-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
120 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "ProteinChains" | ||
uuid = "b8e8f2a5-48d3-44f1-ba0d-c71cb7726ff8" | ||
authors = ["Anton Oresten <[email protected]> and contributors"] | ||
version = "0.3.1" | ||
version = "0.3.2" | ||
|
||
[deps] | ||
AssigningSecondaryStructure = "8ed43e74-60fb-4e11-99b9-91deed37aef7" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,41 @@ | ||
const missingvals = Set([".", "?"]) | ||
|
||
""" | ||
renumber!(structure::ProteinStructure, mmcif_dict::BioStructures.MMCIFDict) | ||
renumber(structure::ProteinStructure, mmcif_dict::BioStructures.MMCIFDict) | ||
Return residue numbers from "_atom_site.label_seq_ids". | ||
Renumber the residues in a `ProteinStructure` object according to the numbering aligned to a reference sequence in the MMCIF file. | ||
The `ProteinStructure` will automatically add a `renumbering` property if | ||
an MMCIFDict is passed (default if the file is an MMCIF). | ||
""" | ||
function renumber!(structure::ProteinStructure, mmcif_dict::BioStructures.MMCIFDict) | ||
function renumber(structure::ProteinStructure, mmcif_dict::BioStructures.MMCIFDict) | ||
label_seq_ids = mmcif_dict["_atom_site.label_seq_id"] | ||
pdbx_PDB_ins_codes = mmcif_dict["_atom_site.pdbx_PDB_ins_code"] | ||
auth_seq_ids = mmcif_dict["_atom_site.auth_seq_id"] | ||
auth_asym_ids = mmcif_dict["_atom_site.auth_asym_id"] | ||
reduced = Int[] | ||
current_auth_seq_id = "" | ||
for (i, auth_seq_id) in enumerate(auth_seq_ids) | ||
current_auth_seq_id == auth_seq_id && continue | ||
current_auth_seq_id = auth_seq_id | ||
push!(reduced, i) | ||
end | ||
|
||
label_seq_ids = label_seq_ids[reduced] | ||
auth_seq_ids = auth_seq_ids[reduced] | ||
auth_asym_ids = auth_asym_ids[reduced] | ||
|
||
chainwise_auth_to_label_seq_ids = Dict{String,Dict{String,String}}() | ||
label_seq_id_dict = Dict{String,String}() | ||
|
||
for asym_id in unique(auth_asym_ids) | ||
indices = auth_asym_ids .== asym_id | ||
chainwise_auth_to_label_seq_ids[asym_id] = Dict(zip(auth_seq_ids[indices], label_seq_ids[indices])) | ||
indices = findall(auth_asym_ids .== asym_id) | ||
for i in indices | ||
ins_code = pdbx_PDB_ins_codes[i] == "?" ? " " : pdbx_PDB_ins_codes[i] | ||
key = asym_id*auth_seq_ids[i]*ins_code | ||
!haskey(label_seq_id_dict, key) && (label_seq_id_dict[key] = label_seq_ids[i]) | ||
end | ||
end | ||
|
||
chainwise_renumbering = Vector{Int32}[] | ||
for chain in structure | ||
renum_dict = chainwise_auth_to_label_seq_ids[chain.id] | ||
numbering_str = map(n -> get(renum_dict, n, "?"), string.(chain.numbering)) | ||
"?" in numbering_str && break | ||
chain.numbering .= parse.(Int, numbering_str) | ||
if length(chain) == 0 | ||
push!(chainwise_renumbering, Int32[]) | ||
continue | ||
end | ||
renumbering_str = map( | ||
(resnum, ins_code) -> parse(Int32, get(label_seq_id_dict, chain.id*string(resnum)*ins_code, "-1")), chain.numbering, | ||
hasproperty(chain, :ins_codes) ? Iterators.map(Char, chain.ins_codes) : Iterators.repeated(' ')) | ||
push!(chainwise_renumbering, renumbering_str) | ||
end | ||
|
||
return structure | ||
return chainwise_renumbering | ||
end | ||
|
||
#=function renumber!(structure::ProteinStructure, mmcif_dict::BioStructures.MMCIFDict) | ||
asym_ids = mmcif_dict["_pdbx_poly_seq_scheme.asym_id"] | ||
auth_seq_nums = map(s -> s == "?" ? -1 : parse(Int, s), mmcif_dict["_pdbx_poly_seq_scheme.auth_seq_num"]) | ||
ndb_seq_nums = map(s -> s == "?" ? -1 : parse(Int, s), mmcif_dict["_pdbx_poly_seq_scheme.ndb_seq_num"]) | ||
amino_acids = map(s -> get(BioStructures.threeletter_to_aa, s, BioStructures.AA_X), mmcif_dict["_pdbx_poly_seq_scheme.mon_id"]) | ||
chainwise_auth_to_ndb = Dict{String,Dict{Int,Int}}() | ||
chainwise_sequences = Dict{String,String}() | ||
for asym_id in unique(asym_ids) | ||
indices = asym_ids .== asym_id | ||
chainwise_auth_to_ndb[asym_id] = Dict(zip(auth_seq_nums[indices], ndb_seq_nums[indices])) | ||
chainwise_sequences[asym_id] = join(amino_acids[indices]) | ||
end | ||
for chain in structure | ||
chain.numbering = map(n -> chainwise_auth_to_ndb[chain.id][n], chain.numbering) | ||
chain.sequence_reference = chainwise_sequences[chain.id] | ||
end | ||
return structure | ||
end=# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters