# HG changeset patch # User immport-devteam # Date 1488218831 18000 # Node ID e1f0194cf8fc72cf3b982c71dd77fe118d4487c7 Uploaded diff -r 000000000000 -r e1f0194cf8fc txt_diagnosis/test-data/input_error.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/txt_diagnosis/test-data/input_error.txt Mon Feb 27 13:07:11 2017 -0500 @@ -0,0 +1,16 @@ +Forward Scatter Side Scatter FITC CD4 PE CD25 PP CD3 APC CD45RA +289 56 438 0 626 nan +352 153 30 147 483 386 +383 190 156 228 734 408 +261 62 432 121 598 555 +451 120 537 338 568 nba +373 104 3 110 621 584 +418 105 561 0 610 562 +358 185 0 292 641 327 +733 970 139 227 293 259 +765 1023 71 239 bkl 253 +762 957 143 158 271 255 +406 191 513 122 646 264 +695 1023 168 251 234 283 +336 178 0 146 128 we +668 1023 167 306 302 253 diff -r 000000000000 -r e1f0194cf8fc txt_diagnosis/test-data/input_noerror.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/txt_diagnosis/test-data/input_noerror.txt Mon Feb 27 13:07:11 2017 -0500 @@ -0,0 +1,16 @@ +Forward Scatter Side Scatter FITC CD4 PE CD25 PP CD3 APC CD45RA +289 56 438 0 626 0 +352 153 30 147 483 386 +383 190 156 228 734 408 +261 62 432 121 598 555 +451 120 537 338 568 111 +373 104 3 110 621 584 +418 105 561 0 610 562 +358 185 0 292 641 327 +733 970 139 227 293 259 +765 1023 71 239 54 253 +762 957 143 158 271 255 +406 191 513 122 646 264 +695 1023 168 251 234 283 +336 178 0 146 128 35 +668 1023 167 306 302 253 diff -r 000000000000 -r e1f0194cf8fc txt_diagnosis/test-data/output_error.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/txt_diagnosis/test-data/output_error.txt Mon Feb 27 13:07:11 2017 -0500 @@ -0,0 +1,3 @@ +WARNING: line 6 in input_error.txt contains non-numeric results +WARNING: line 11 in input_error.txt contains non-numeric results +WARNING: line 15 in input_error.txt contains non-numeric results diff -r 000000000000 -r e1f0194cf8fc txt_diagnosis/test-data/output_noerror.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/txt_diagnosis/test-data/output_noerror.txt Mon Feb 27 13:07:11 2017 -0500 @@ -0,0 +1,1 @@ +No errors in the file. diff -r 000000000000 -r e1f0194cf8fc txt_diagnosis/txtDiagnosis.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/txt_diagnosis/txtDiagnosis.xml Mon Feb 27 13:07:11 2017 -0500 @@ -0,0 +1,75 @@ + + in txt-converted FCS files. + + pandas + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 000000000000 -r e1f0194cf8fc txt_diagnosis/txtdiagnosis.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/txt_diagnosis/txtdiagnosis.py Mon Feb 27 13:07:11 2017 -0500 @@ -0,0 +1,68 @@ +#!/usr/bin/env python +###################################################################### +# Copyright (c) 2016 Northrop Grumman. +# All rights reserved. +###################################################################### +from __future__ import print_function +from __future__ import division +import pandas as pd +from argparse import ArgumentParser +import sys + + +def is_number(s): + try: + float(s) + return True + except ValueError: + return False + + +def error_report(input_file, fname, output_file): + errors = 0 + df = pd.read_table(input_file) + with open(output_file, "w") as outf: + for cols in df.columns.values: + if df[cols].count() != len(df[cols]): + with open(input_file, "r") as checkfile: + fl = checkfile.readline() + count_lines = 1 + for checklines in checkfile: + to_check = checklines.strip().split("\t") + count_lines += 1 + for item in to_check: + if not is_number(item): + errors += 1 + outf.write(" ".join(["WARNING: line", str(count_lines), "in", fname, "contains non-numeric results\n"])) + if errors == 0: + outf.write("No errors in the file.\n") + return + + +if __name__ == "__main__": + parser = ArgumentParser( + prog="txtDiagnosis", + description="Reports potential errors in text-converted FCS files") + + parser.add_argument( + '-i', + dest="input_file", + required=True, + help="File location for the text file.") + + parser.add_argument( + '-n', + dest="filename", + required=True, + help="Filename location for the text file.") + + parser.add_argument( + '-o', + dest="output_file", + required=True, + help="Name of the output file.") + + args = parser.parse_args() + + error_report(args.input_file, args.filename, args.output_file) + sys.exit(0)