Mercurial > repos > devteam > table_annovar
comparison replace_NA.py @ 8:d4e292ddda05 draft default tip
"planemo upload for repository Nonehttps://github.com/galaxyproject/tools-devteam/tree/master/tools/table_annovar commit 68ba77da2a1f8d6cd04dd7dc6efc5edcefcfa0c9"
| author | devteam |
|---|---|
| date | Thu, 05 May 2022 13:13:11 +0000 |
| parents | 5cb2020a097a |
| children |
comparison
equal
deleted
inserted
replaced
| 7:08b003ee9db7 | 8:d4e292ddda05 |
|---|---|
| 61 # Close temp file so that it can be read. | 61 # Close temp file so that it can be read. |
| 62 temp_name = temp_out.name | 62 temp_name = temp_out.name |
| 63 temp_out.close() | 63 temp_out.close() |
| 64 | 64 |
| 65 # Get column type based on label or consensus. | 65 # Get column type based on label or consensus. |
| 66 col_types = range(len(col_type_counts)) | 66 col_types = list(range(len(col_type_counts))) |
| 67 for i, counts in enumerate(col_type_counts): | 67 for i, counts in enumerate(col_type_counts): |
| 68 if i in numerical_cols: | 68 if i in numerical_cols: |
| 69 col_type = 'number' | 69 col_type = 'number' |
| 70 elif counts[0] > counts[1]: | 70 elif counts[0] > counts[1]: |
| 71 col_type = 'string' | 71 col_type = 'string' |
| 77 for line in open(temp_name, 'r'): | 77 for line in open(temp_name, 'r'): |
| 78 fields = line.strip().split(SEPARATOR) | 78 fields = line.strip().split(SEPARATOR) |
| 79 for i, f in enumerate(fields): | 79 for i, f in enumerate(fields): |
| 80 if fields[i] == TARGET and col_types[i] == 'number': | 80 if fields[i] == TARGET and col_types[i] == 'number': |
| 81 fields[i] = str(REPLACEMENT) | 81 fields[i] = str(REPLACEMENT) |
| 82 print SEPARATOR.join(fields) | 82 print(SEPARATOR.join(fields)) |
| 83 | 83 |
| 84 # Clean up temp file. | 84 # Clean up temp file. |
| 85 temp_out.close() | 85 temp_out.close() |
| 86 os.unlink(temp_out.name) | 86 os.unlink(temp_out.name) |
| 87 | 87 |
