This repository has been archived by the owner on Nov 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Coos Baakman
committed
Apr 6, 2021
1 parent
a34cb9e
commit 075c39b
Showing
4 changed files
with
126 additions
and
23 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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
|
||
class Atom: | ||
def __init__(self, id_, position, chain_id, name, residue=None): | ||
self.id = id_ | ||
self.name = name | ||
self.chain_id = chain_id | ||
self.position = position | ||
self.residue = residue | ||
|
||
def __hash__(self): | ||
return hash(self.id) | ||
|
||
def __eq__(self, other): | ||
return self.id == other.id | ||
|
||
def __lt__(self, other): | ||
return self.id < other.id | ||
|
||
def __repr__(self): | ||
return "Atom {} ({} {} {}) at {}".format(self.id, self.chain_id, self.residue, self.name, self.position) | ||
|
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
|
||
|
||
class Residue: | ||
def __init__(self, number, name, atoms=[]): | ||
self.number = number | ||
self.name = name | ||
self.atoms = atoms | ||
|
||
@property | ||
def chain_id(self): | ||
chain_ids = set([atom.chain_id for atom in self.atoms]) | ||
if len(chain_ids) > 1: | ||
raise ValueError("residue {} {} contains atoms of different chains: {}".format(self.name, self.number, self.atoms)) | ||
|
||
return list(chain_ids)[0] | ||
|
||
def __hash__(self): | ||
return hash((self.chain_id, self.number)) | ||
|
||
def __eq__(self, other): | ||
return self.chain_id == other.chain_id and self.number == other.number | ||
|
||
def __repr__(self): | ||
return "Residue {} {}".format(self.name, self.number) |
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