Commit 9d96d282 authored by Jerome Mariette's avatar Jerome Mariette

add sequences stat

parent 7604ea07
......@@ -32,7 +32,7 @@ from ng6.t3MySQLdb import t3MySQLdb
from ng6.config_reader import NG6ConfigReader
from ng6.utils import Utils
from ng6.exceptions import UnsavedRunError
from ng6 import seqio
class Run(object):
"""
......@@ -87,6 +87,23 @@ class Run(object):
os.makedirs(work_dir, 0751)
self.directory = os.path.join(self.DIRECTORIES_STRUCTURE, directory_name)
def add_raw_files(self, files, mode):
"""
Copy, archive and compress the files list to the run. And add info to the run
the script add_raw_files.
@param files: the files to archive
@param mode: can be none, gz, bz2, tar.gz and tar.bz2
"""
nb_seq, full_size = 0, 0
for file in files:
# Get nb_seq and full_size values
reader = seqio.SequenceReader(file)
for id, desc, seq, qualities in reader:
nb_seq += 1
full_size += len(seq)
self.set_nb_sequences(nb_seq)
self.set_full_size(full_size)
self.archive_files(files, mode)
def archive_files(self, files, mode, archive_name="ng6_archive.tar", delete=False):
"""
......
......@@ -302,8 +302,8 @@ class t3MySQLdb(object):
req += "sequencer='" + sequencer.replace("'", "\'") + "', "
req = req[:-1] #remove last comma for WHERE
req += "WHERE uid = '"+ str(run_id) + "'"
conn.commit()
curs.execute(req)
conn.commit()
conn.close()
......
......@@ -43,7 +43,7 @@ class AddRun (Workflow):
my_run = Run(self.args["run_name"], datetime.date(int(run_date[2]), int(run_date[1]), int(run_date[0])),
self.args["species"], self.args["data_nature"], self.args["type"], self.args["run_description"],
self.args["sequencer"])
# archive the files
my_run.archive_files(files_to_save, self.args["archive_mode"])
# Then add the run to the project
my_project.add_run(my_run)
# archive the files
my_run.add_raw_files(files_to_save, self.args["archive_mode"])
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment