New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'Residue' object has no attribute 'sort' #4075
Comments
You are looking at the (old) documentation for Biopython 1.75. This method was deprecated (not sure when) and removed in Biopython 1.79, quoting
That method therefore isn't listed in the current documentation: https://biopython.org/docs/latest/api/Bio.PDB.Residue.html |
Ok I got you ! so do you have an alternative way to sort atoms after removing it in the new version ? |
The deprecation message was: See also #1360. |
I used the built-in sorted() methods but it does not solve the problem I hope that they will bring back the sort method, it was perfect ! |
Can you paste your code and what the error is when you use sorted ()?
A quinta, 8/09/2022, 08:26, raoufks ***@***.***> escreveu:
… I used the built-in sorted() methods but it does not solve the problem
I hope that they will bring back the sort method, it was perfect !
—
Reply to this email directly, view it on GitHub
<#4075 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABZ6ECAAJJIKYVECHV2N23V5HLQHANCNFSM6AAAAAAQHPRMSQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
It works BUT my goal is to sort atoms in a PDB, ..., my problem is therefore in this case after sorting with built-in sorted method, I want to save them in the residue, something that was doable with only PDB
python code in_pdb_file = "/home/raouf-ks/Downloads/7nd4_custom.pdb"
out_pdb_file="/home/raouf-ks/Downloads/7nd4_custom_sorted.pdb"
p = PDBParser()
structure = p.get_structure(in_pdb_file, in_pdb_file)
for model in structure:
for chain in model:
for residue in chain:
print("before : ", [a for a in residue.get_atoms()])
print("after : ", [a for a in sorted(residue.get_atoms())])
# HOW TO SAVE THE SORTED ATOMS
break
break
break
# save
io = PDBIO()
io.set_structure(structure)
io.save(out_pdb_file) output
|
That's an entirely different (and valid!) problem :)
Will look into it.
A quinta, 8/09/2022, 09:31, raoufks ***@***.***> escreveu:
… It works BUT my goal is to sort atoms in a PDB, ..., my problem is
therefore in this case after sorting with built-in sorted method, I want to
save them in the residue, something that was doable with only
residue.sort()
*PDB*
ATOM 1 C ALA A 27 110.972 180.723 157.553 1.00 81.55 C
ATOM 2 O ALA A 27 111.891 180.818 158.365 1.00 81.55 O
ATOM 3 CB ALA A 27 109.037 182.248 157.980 1.00 81.55 C
ATOM 4 N ALA A 27 109.355 180.240 159.340 1.00 81.55 N
ATOM 5 CA ALA A 27 109.519 180.807 158.006 1.00 81.55 C
ATOM 6 N TYR A 28 111.174 180.539 156.250 1.00 83.54 N
ATOM 7 CA TYR A 28 112.503 180.472 155.666 1.00 83.54 C
ATOM 8 C TYR A 28 112.548 181.334 154.414 1.00 83.54 C
ATOM 9 O TYR A 28 111.532 181.534 153.744 1.00 83.54 O
ATOM 10 CB TYR A 28 112.891 179.030 155.316 1.00 83.54 C
ATOM 11 CG TYR A 28 113.043 178.122 156.516 1.00 83.54 C
ATOM 12 CD1 TYR A 28 111.936 177.531 157.109 1.00 83.54 C
ATOM 13 CD2 TYR A 28 114.294 177.851 157.052 1.00 83.54 C
ATOM 14 CE1 TYR A 28 112.069 176.701 158.205 1.00 83.54 C
ATOM 15 CE2 TYR A 28 114.437 177.020 158.147 1.00 83.54 C
ATOM 16 CZ TYR A 28 113.322 176.449 158.720 1.00 83.54 C
ATOM 17 OH TYR A 28 113.461 175.620 159.809 1.00 83.54 O
*python code*
in_pdb_file = "/home/raouf-ks/Downloads/7nd4_custom.pdb"p = PDBParser()structure = p.get_structure(in_pdb_file, in_pdb_file)for model in structure:
for chain in model:
for residue in chain:
print("before : ", [a for a in residue.get_atoms()])
print("after : ", [a for a in sorted(residue.get_atoms())])
# HOW TO SAVE THE SORTED ATOMS
break
break
break
# save the new structureif not out_pdb_file:
out_pdb_file = in_pdb_file
io = PDBIO()io.set_structure(structure)io.save(out_pdb_file)
*output*
before : [<Atom C>, <Atom O>, <Atom CB>, <Atom N>, <Atom CA>]
after : [<Atom N>, <Atom CA>, <Atom C>, <Atom O>, <Atom CB>]
—
Reply to this email directly, view it on GitHub
<#4075 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABZ6EDLM6UHWVO66FNTMFTV5HTE5ANCNFSM6AAAAAAQHPRMSQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@JoaoRodrigues residue.child_list.sort() |
Code
I am reporting a problem with Biopython version, Python version, and operating
system as follows:
Output
the methode sort according to the documentation should sort child atoms, where N, CA, C, O always come first, thereafter alphabetically by name, with any alternative location specifier for disordered atoms (altloc) as a tie-breaker.
but it is not working !
The text was updated successfully, but these errors were encountered: