Skip to content

Commit

Permalink
Clean code. [Issue #26] (#29)
Browse files Browse the repository at this point in the history
* Removed all unused/unnecessary lines.
  • Loading branch information
Estefania Barreto-Ojeda committed Jun 18, 2021
1 parent 72a78ec commit bf6019b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 176 deletions.
56 changes: 0 additions & 56 deletions membrane_curvature/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,66 +18,10 @@

sys.path.append('lib/')


class Grid():
# instance variables
def __init__(self, box_width, max_width, unit_cell_width, skip):
self.box_width = box_width
self.max_width = max_width
self.unit_cell_width = unit_cell_width
self.skip = skip
self.n_cells = math.ceil(max_width / unit_cell_width * 10)


class head_indexes:
# class variables
leaflets = ['lower', 'upper']

# instance variables
def __init__(self, lipid_types, head_index, top):
self.lipid_types = lipid_types
self.head_index = head_index
self.top = top

# @classmethod
def list_head_beads(self):
lfs = self.leaflets
return def_all_beads(self.lipid_types, lfs, self.head_index, self.top)


def main():

start_time = time.time()

# 1. Parse input files
parser = input_options()

args = parser.parse_args()
grofile, trjfile = args.f, args.x
unit_width, jump = args.uw, args.sk
output = args.out

try:
name_user = str(args.name)
print("Prefix assigned by user. Set as {}".format(name_user))

except NameError:
name_user = 'system'
print("Prefix not assigned by user. Set as {}".format(name_user))

# Define index leaflets
ii, jj = parse_range(args.io), parse_range(args.ii)
iil, iiu = def_range_leaflets(args.io, 1)
jjl, jju = def_range_leaflets(args.ii, 2)

# 2 --- Set OUTPUT files
# 2.1 Create output folder
os.makedirs(os.path.dirname('output/'), exist_ok=True)

# 2.2 -- Pickle files (head group height)
prefix = name_user
name_ = output + prefix

# 3. Define leaflets and lipid type
leaflets = ['lower', 'upper']

Expand Down
120 changes: 0 additions & 120 deletions membrane_curvature/lib/mods.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,126 +4,6 @@
import math


class Grid:

"""
A class to set a grid with n x n elements.
...
Attributes
----------
[Names are self explanatory]
box_width : <float>
Box dimensions in x.
max_width : <int>
Max width of the grid.
unit_cell_width(): <int>
Width of unit cell in grid.
Methods
-------
list_by_index(additional=""):
Returns list with [inner_leaflet_first_index, upper_leaflet_first_index, upper_leaflet_last_index].
"""

# instance variables
def __init__(self, box_width, max_width, unit_cell_width):
self.box_width = box_width
self.max_width = max_width
self.unit_cell_width = unit_cell_width
self.n_cells = math.ceil(max_width / unit_cell_width * 10)


class define_leaflets:

"""
A class to define leaflets by index when provided by the user.
...
Attributes
----------
int_inner : str:str
Index interval of the inner leaflet.
surname : str:str
Index interval of the outer leaflet.
Methods
-------
list_by_index():
Returns list [i for i in range(<index interval>)]].
"""

def __init__(self, int_inner, int_upper):
self.int_inner = int_inner
self.int_upper = int_upper

def list_by_index(self):
ii, jj = parse_range(self.int_upper), parse_range(self.int_inner)
iil, iiu = def_range_leaflets(self.int_upper, 1)
jjl, jju = def_range_leaflets(self.int_inner, 2)

return [iil, jjl, jju]


class membrane_index:

"""
A class to select PO4 beads from defined leaflets.
...
Attributes
----------
lipid_types : <list>
Index interval of the inner leaflet.
head_index : <>
Index interval of the outer leaflet.
Methods
-------
list_head_beads():
Returns list with [inner_leaflet_first_index, upper_leaflet_first_index, upper_leaflet_last_index].
"""

# class variables
leaflets = ['upper', 'lower']

# instance variables
def __init__(self, lipid_types, head_index, top):
self.lipid_types = lipid_types
self.head_index = head_index
self.top = top

# #@classmethod
def list_head_beads(self):
return def_po4_beads(self.lipid_types, self.leaflets, self.head_index, self.top)


def parse_range(astr):
"""
Split range provided by user
"""

rangeG = set()
x = [int(i) for i in astr.split(':')]
rangeG.update(range(x[0], x[1] + 1))

return list(rangeG)


def def_range_leaflets(nn, ind):
"""
Define range of index residues
"""
mm = parse_range(nn)

return min(mm), max(mm)


def def_all_beads(lipid_types, leaflets, head_list, topology):
"""
Select reference elements to derive membrane surface.
Expand Down

0 comments on commit bf6019b

Please sign in to comment.