File: cnv_annotate.py

package info (click to toggle)
cnvkit 0.9.9-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 70,536 kB
  • sloc: python: 9,707; makefile: 305; sh: 53; xml: 38
file content (33 lines) | stat: -rwxr-xr-x 959 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/python3
"""Update gene names in CNVkit .cnn/.cnr files.
"""
import argparse
import logging
import sys

from skgenome import tabio
from cnvlib.cmdutil import read_cna

logging.basicConfig(level=logging.INFO, format="%(message)s")


def main(args):
    annot = tabio.read_auto(args.annotate)
    cnarr = read_cna(args.cnv_file)
    cnarr['gene'] = annot.into_ranges(cnarr, 'gene', '-')
    tabio.write(cnarr, args.output or sys.stdout)
    # ENH:
    #  --short-names
    #  --no-antitarget
    #  annotation: --merge, --flatten, --exons, ...
    #  cut antitargets & insert untargeted gene names
    #      some math for how to update probes, weight



if __name__ == '__main__':
    AP = argparse.ArgumentParser(description=__doc__)
    AP.add_argument('annotate', help="Genome annotations.")
    AP.add_argument('cnv_file', help="CNVkit .cnn or .cnr file.")
    AP.add_argument('-o', '--output', help="Output filename.")
    main(AP.parse_args())