Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change CRISPResso_status.txt format to JSON #46

Merged
merged 41 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8bd75e5
Bug Fix - 367 (#35)
mbowcut2 Mar 14, 2024
7465470
add json read for status file
mbowcut2 Mar 11, 2024
af7ec4f
changed Formatter to json format
mbowcut2 Mar 12, 2024
55d7b23
fixed json access variable name: message
mbowcut2 Mar 13, 2024
31ed12e
changed perentage_complete to numeric
mbowcut2 Mar 13, 2024
f0f8887
changed status file to .json
mbowcut2 Mar 14, 2024
518097d
Create integration_tests.yml
Snicker7 Feb 22, 2024
1bdd92c
Simplify name
Snicker7 Feb 22, 2024
6674e40
CRISPRESSO2_DIR environment variable
Snicker7 Feb 22, 2024
5114829
Up one dir
Snicker7 Feb 22, 2024
714d401
ls workspace
Snicker7 Feb 22, 2024
86db6d6
Install CRISPResso and ydiff
Snicker7 Feb 22, 2024
8a22c75
Clone repo instead of checkout
Snicker7 Feb 22, 2024
65169fd
submodule
Snicker7 Feb 22, 2024
45ef982
ls
Snicker7 Feb 22, 2024
37cbe9b
CRISPResso2_copy
Snicker7 Feb 22, 2024
c322e18
ls
Snicker7 Feb 22, 2024
6642f54
Update env
Snicker7 Feb 22, 2024
8faaa60
Simplify
Snicker7 Feb 22, 2024
4b1d503
Pull from githubactions branch
Snicker7 Feb 29, 2024
077de45
Pull githubactions repo
Snicker7 Feb 29, 2024
316b526
Checkout githubactions
Snicker7 Feb 29, 2024
08f0d2b
Run tests individually
Snicker7 Mar 13, 2024
56ec1ca
Pin plotly version
Snicker7 Mar 13, 2024
095ac4b
Run all tests even if one fails
Snicker7 Mar 13, 2024
d3fbda3
Test on another branch
Snicker7 Mar 14, 2024
450de0d
Switch branch with token
Snicker7 Mar 14, 2024
50b2063
Update integration_tests.yml
Snicker7 Mar 14, 2024
cfe4389
New makefile commands
Snicker7 Mar 14, 2024
a832f5f
changed file to .json
mbowcut2 Mar 14, 2024
797e327
changed status to json file
mbowcut2 Mar 14, 2024
86ded51
Make JSON human readable by adding new lines
Colelyman Mar 15, 2024
f6e1906
GitHub actions integration tests (#48)
Snicker7 Mar 15, 2024
bb06075
Move read filtering to after merging in CRISPResso (#39)
Colelyman Mar 22, 2024
1c6d210
GitHub actions on pr (#51)
Snicker7 Mar 22, 2024
da7c0cc
Run tests on PR only when opening PR (#53)
Snicker7 Mar 22, 2024
b04352d
Update reports (#52)
Colelyman Mar 25, 2024
bbb5a9a
point to test branch
mbowcut2 Apr 1, 2024
80914fb
pointed CI config to testing branch
mbowcut2 Apr 1, 2024
83fc345
Update integration_tests.yml
mbowcut2 Apr 4, 2024
0c3b678
Merge branch 'master' into mckay/status_json
mbowcut2 Apr 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoAggregateCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def main():

log_filename=_jp('CRISPRessoAggregate_RUNNING_LOG.txt')
logger.addHandler(logging.FileHandler(log_filename))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoAggregate_status.txt')))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoAggregate_status.json')))

with open(log_filename, 'w+') as outfile:
outfile.write('[Command used]:\n%s\n\n[Execution log]:\n' % ' '.join(sys.argv))
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoBatchCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def main():

log_filename = _jp('CRISPRessoBatch_RUNNING_LOG.txt')
logger.addHandler(logging.FileHandler(log_filename))
status_handler = CRISPRessoShared.StatusHandler(_jp('CRISPRessoBatch_status.txt'))
status_handler = CRISPRessoShared.StatusHandler(_jp('CRISPRessoBatch_status.json'))
logger.addHandler(status_handler)

with open(log_filename, 'w+') as outfile:
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ def print_stacktrace_if_debug():
with open(log_filename, 'w+') as outfile:
outfile.write('CRISPResso version %s\n[Command used]:\n%s\n\n[Execution log]:\n' %(CRISPRessoShared.__version__, crispresso_cmd_to_write))

logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPResso_status.txt')))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPResso_status.json')))

aln_matrix_loc = os.path.join(_ROOT, "EDNAFULL")
CRISPRessoShared.check_file(aln_matrix_loc)
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoCompareCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def main():

log_filename = _jp('CRISPRessoCompare_RUNNING_LOG.txt')
logger.addHandler(logging.FileHandler(log_filename))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoCompare_status.txt')))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoCompare_status.json')))

with open(log_filename, 'w+') as outfile:
outfile.write('[Command used]:\nCRISPRessoCompare %s\n\n[Execution log]:\n' % ' '.join(sys.argv))
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoMetaCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def main():

log_filename=_jp('CRISPRessoMeta_RUNNING_LOG.txt')
logger.addHandler(logging.FileHandler(log_filename))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoMeta_status.txt')))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoMeta_status.json')))

with open(log_filename, 'w+') as outfile:
outfile.write('[Command used]:\n%s\n\n[Execution log]:\n' % ' '.join(sys.argv))
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoPooledCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def main():

log_filename = _jp('CRISPRessoPooled_RUNNING_LOG.txt')
logger.addHandler(logging.FileHandler(log_filename))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoPooled_status.txt')))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoPooled_status.json')))

if args.zip_output and not args.place_report_in_output_folder:
logger.warn('Invalid arguement combination: If zip_output is True then place_report_in_output_folder must also be True. Setting place_report_in_output_folder to True.')
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoPooledWGSCompareCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def main():

log_filename = _jp('CRISPRessoPooledWGSCompare_RUNNING_LOG.txt')
logger.addHandler(logging.FileHandler(log_filename))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoPooledWGSCompare_status.txt')))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoPooledWGSCompare_status.json')))

with open(log_filename, 'w+') as outfile:
outfile.write(
Expand Down
45 changes: 28 additions & 17 deletions CRISPResso2/CRISPRessoShared.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class StatusFormatter(logging.Formatter):
def format(self, record):
record.percent_complete = ''
if record.args and 'percent_complete' in record.args:
record.percent_complete = '{0:.2f}% '.format(record.args['percent_complete'])
record.percent_complete = float(record.args['percent_complete'])
self.last_percent_complete = record.percent_complete
elif hasattr(self, 'last_percent_complete'): # if we don't have a percent complete, use the last one
record.percent_complete = self.last_percent_complete
Expand All @@ -101,7 +101,7 @@ def format(self, record):
class StatusHandler(logging.FileHandler):
def __init__(self, filename):
super().__init__(filename, 'w')
self.setFormatter(StatusFormatter('%(percent_complete)s%(message)s'))
self.setFormatter(StatusFormatter('{\n "message": "%(message)s",\n "percent_complete": %(percent_complete)s\n}'))

def emit(self, record):
"""Overwrite the existing file and write the new log."""
Expand Down Expand Up @@ -896,7 +896,7 @@ def write_crispresso_info(crispresso_output_file, crispresso2_info):

"""
with open(crispresso_output_file, 'w') as fh:
json.dump(crispresso2_info, fh, cls=CRISPRessoJSONEncoder)
json.dump(crispresso2_info, fh, cls=CRISPRessoJSONEncoder, indent=2)


def get_command_output(command):
Expand Down Expand Up @@ -1045,7 +1045,7 @@ def check_if_failed_run(folder_name, info):
"""

run_data_file = os.path.join(folder_name, 'CRISPResso2_info.json')
status_info = os.path.join(folder_name, 'CRISPResso_status.txt')
status_info = os.path.join(folder_name, 'CRISPResso_status.json')
if not os.path.isfile(run_data_file) or not os.path.isfile(status_info):
info("Skipping folder '%s'. Cannot find run data status file at '%s'."%(folder_name, run_data_file))
if "CRISPRessoPooled" in folder_name:
Expand All @@ -1059,20 +1059,31 @@ def check_if_failed_run(folder_name, info):
else:
with open(status_info) as fh:
try:
file_contents = fh.read()
search_result = re.search(r'(\d+\.\d+)% (.+)', file_contents)
if search_result:
percent_complete, status = search_result.groups()
if percent_complete != '100.00':
info("Skipping folder '%s'. Run is not complete (%s)." % (folder_name, status))
return True, status
status_dict = json.load(fh)
if status_dict['percent_complete'] != 100.0:
info("Skipping folder '%s'. Run is not complete (%s)." % (folder_name, status_dict['status']))
return True, str(status_dict['message'])
else:
return True, file_contents
except Exception as e:
print(e)
info("Skipping folder '%s'. Cannot parse status file '%s'." % (folder_name, status_info))
return True, "Cannot parse status file '%s'." % (status_info)
return False, ""
return False, ""
except:
pass

with open(status_info) as fh:
try:
file_contents = fh.read()
search_result = re.search(r'(\d+\.\d+)% (.+)', file_contents)
if search_result:
percent_complete, status = search_result.groups()
if percent_complete != '100.00':
info("Skipping folder '%s'. Run is not complete (%s)." % (folder_name, status))
return True, status
else:
return True, file_contents
except Exception as e:
print(e)
info("Skipping folder '%s'. Cannot parse status file '%s'." % (folder_name, status_info))
return True, "Cannot parse status file '%s'." % (status_info)
return False, ""


def guess_amplicons(fastq_r1,fastq_r2,number_of_reads_to_consider,flash_command,max_paired_end_reads_overlap,min_paired_end_reads_overlap,aln_matrix,needleman_wunsch_gap_open,needleman_wunsch_gap_extend,split_interleaved_input=False,min_freq_to_consider=0.2,amplicon_similarity_cutoff=0.95):
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoWGSCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def print_stacktrace_if_debug():
except:
warn('Folder %s already exists.' % OUTPUT_DIRECTORY)

logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoWGS_status.txt')))
logger.addHandler(CRISPRessoShared.StatusHandler(_jp('CRISPRessoWGS_status.json')))

info('Checking dependencies...')

Expand Down
Loading