-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.py
executable file
·35 lines (30 loc) · 1008 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python
import numpy as np
import os.path
def isoCount (myVars):
if hasattr(myVars, '__iter__'):
cnt = len(myVars)
else:
cnt = 1
return cnt
def flatten_list(myVars, return_list=0):
""" Isoforms are being treated together as a group. To delineate them,
isoforms are grouped together as tuples. For the calis statement, xvar and
yvar need to each be a string. This function flattens these tuples into a
single list and creates a string. """
result = []
for element in myVars:
if hasattr(element, '__iter__'):
# if tuple flatten and append
result.extend(element)
else:
# if not a tuple just append
result.append(element)
if return_list:
return result
else:
return(' '.join(result))
def name_scrub(name):
""" Function to scrub path and extension from a file name """
cleanName = os.path.splitext(os.path.basename(name))[0]
return cleanName