-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
50 lines (45 loc) · 1.49 KB
/
utils.py
File metadata and controls
50 lines (45 loc) · 1.49 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import curses
def deleteChar(var):
if len(var)>0:
var=var[0:len(var)-1]
return var
def statusbar(stdscr,text="Press 'q' to exit | Press 'enter' to continu"):
statusbarstr = text
height, width = stdscr.getmaxyx()
stdscr.attron(curses.color_pair(3))
stdscr.addstr(height-1, 0, statusbarstr)
stdscr.addstr(height-1, len(statusbarstr), " " * (width - len(statusbarstr) - 1))
stdscr.attroff(curses.color_pair(3))
def read_FASTA_strings(filename):
with open(filename) as file:
return (file.read()).split('>')
def save_to_file(results, filename="resultat.txt"):
try:
with open(filename, "w") as file:
for result in results:
file.write(result)
print(f"Résultats enregistrés avec succès dans {filename}.")
except Exception as e:
print(f"Error saving results to {filename}: {e}")
def ReadInput(stdscr,text,pos=1):
key=''
input=''
while key != '\n':
stdscr.addstr(text)
stdscr.addstr(f"{input}")
key=stdscr.getkey()
if key != '\n' and key!='KEY_BACKSPACE':
input=input+key
if key=="KEY_BACKSPACE":
input=deleteChar(input)
stdscr.clear()
stdscr.refresh()
return input
def save_matrix_to_file(matrix, filename="resultat.txt"):
try:
with open(filename, "w") as file:
for row in matrix:
file.write(" ".join(map(str, row)))
print(f"Matrix saved to {filename} successfully.")
except Exception as e:
print(f"Error saving matrix to {filename}: {e}")