Commit 51973f9b authored by Romain Feron's avatar Romain Feron
Browse files

Implemented logs file parsing for individual processing order

parent d394bde9
......@@ -6,3 +6,4 @@ from radseq_analysis.file_handler.positions import load_positions_list
from radseq_analysis.file_handler.sequences import get_sequences
from radseq_analysis.file_handler.markers import get_markers
from radseq_analysis.file_handler.coverage import get_coverage
from radseq_analysis.file_handler.logs import get_individuals_order
from radseq_analysis.file_handler.file_open import open_all
def get_individuals_order(log_path, global_parameters):
Parse the denovo_map.log to find the order in which individuals were processed,
which corresponds to the order of the individuals in the catalog.
logs = open_all(log_path)
individuals_order = {}
line = logs.readline()
found = False
while line != 'Depths of Coverage for Processed Samples:\n' and line:
line = logs.readline()
if line == 'Depths of Coverage for Processed Samples:\n':
found = True
if not found:
print('Error: could not detect individuals order in the denovo_map log file.\n')
print('Possible explanations: \n')
print('\t- you are using an old version of Stacks\n')
print('\t- Stacks did not run properly and denovo_map.log is incomplete\n')
print('\t- a newer version of Stacks has changed the log file structure\n')
order = 1
while True:
line = logs.readline()
if line == '\n':
individuals_order[str(order)] = line.split(':')[0]
order += 1
global_parameters.order = individuals_order
......@@ -11,6 +11,7 @@ class Parameters:
......@@ -25,6 +26,7 @@ class Parameters:
self.haplotypes_output_file = haplotypes_output_file
self.individuals_output_file = individuals_output_file
self.popmap = popmap
self.order = order
self.n_males = n_males
self.n_females = n_females
self.species = species
Supports Markdown
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