-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjak_utils.py
executable file
·33 lines (24 loc) · 978 Bytes
/
jak_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
import yaml
import sys
import os
import pkg_resources
import datetime
from jakomics import colors
def header(r=False):
code_name = os.path.basename(sys.argv[0])
yaml_path = os.path.join(os.path.dirname(sys.argv[0]), 'jak_meta.yml')
with open(yaml_path) as f:
data = yaml.load(f, Loader=yaml.FullLoader)
j_version = pkg_resources.get_distribution("jakomics").version
if r == False:
print(
f'{colors.bcolors.BLUE}{code_name} - JAK-BIO v{data["version"]} - JAKomics v{j_version}{colors.bcolors.END}', file=sys.stderr)
else:
return [code_name, f'JAK-BIO v{data["version"]}', f'JAKomics v{j_version}', f'START_TIME {timestamp()}']
def get_yaml(field):
yaml_path = os.path.join(os.path.dirname(sys.argv[0]), 'jak_meta.yml')
with open(yaml_path) as f:
data = yaml.load(f, Loader=yaml.FullLoader)
return data[field]
def timestamp():
return datetime.datetime.now().strftime("%Y%m%d %H:%M:%S")