-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from simpsonlab/add_cyto_fix_script
Add cyto fix script
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
Append a column to the UCSC cytoband file | ||
""" | ||
|
||
import os | ||
import sys | ||
import argparse | ||
import csv | ||
|
||
|
||
def init_args(): | ||
""" | ||
Initialize command line arguments | ||
""" | ||
description = 'Append chromosome identifier column to UCSC cytoband file' | ||
parser = argparse.ArgumentParser(description=description) | ||
parser.add_argument('-f', '--file', required=True, | ||
help='full path to UCSC cytoband file') | ||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
""" | ||
Main program | ||
""" | ||
args = init_args() | ||
fieldnames = ['chrom', 'start', 'end', 'band', 'desc'] | ||
with open(args.file, 'r') as ifh: | ||
reader = csv.DictReader(ifh, delimiter='\t', fieldnames=fieldnames) | ||
for line in reader: | ||
chr_cyto = ''.join(['chr', line['band']]) | ||
print('\t'.join([ | ||
line['chrom'], | ||
line['start'], | ||
line['end'], | ||
line['band'], | ||
line['desc'], | ||
chr_cyto | ||
])) | ||
ifh.close() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
|
||
|
||
#__END__ |