-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_contacts.py
More file actions
107 lines (95 loc) · 4.6 KB
/
get_contacts.py
File metadata and controls
107 lines (95 loc) · 4.6 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import argparse
from contact import Contacts
def main():
args = parse_arguments()
contacts = Contacts(build = args.assembly,
chromosome = args.chromosome,
resolution = args.resolution,
downweighting = args.downweighting)
contacts.get_raw_contacts_from_clusters_file(
clusters_file = args.clusters,
min_cluster_size = args.min_cluster_size,
max_cluster_size = args.max_cluster_size)
contacts.write_contacts_to_file(outfile = args.raw_contacts, fmt = "%1f")
contacts.ice_raw_contacts(raw_contacts_file = args.raw_contacts,
bias_file = args.biases,
iterations = args.iterations,
hicorrector_path = args.hicorrector)
contacts.write_contacts_to_file(outfile = args.iced, fmt = "%1f")
contacts.truncate_to_median_diagonal_value()
contacts.write_contacts_to_file(outfile = args.output, fmt = "%1f")
def parse_arguments():
parser = argparse.ArgumentParser(
description = 'Generates an ICEd matrix of intra- or ' +
'interchromosomal contacts from a cluster file.')
parser.add_argument('--clusters',
metavar = "FILE",
action = "store",
help = "The input clusters file.")
parser.add_argument('--raw_contacts',
metavar = "FILE",
action = "store",
help = "An intermediate file of raw (un-ICEd) " +
"contacts.")
parser.add_argument('--biases',
metavar = "FILE",
action = "store",
help = "An intermediate file of biases generated by " +
"hicorrector.")
parser.add_argument('--iced',
metavar = "FILE",
action = "store",
help = "An intermediate file of ICEd contacts.")
parser.add_argument('-o', '--output',
metavar = "FILE",
action = "store",
help = "The output ICEd and scaled contacts file.")
parser.add_argument('--assembly',
metavar = "ASSEMBLY",
action = "store",
choices = ["mm9", "mm10", "hg19"],
default = "mm9",
help = "The genome assembly. (default mm9)")
parser.add_argument('--chromosome',
metavar = "CHROM",
action = "store",
help = "The chromosome of interest. Input 'genome' " +
"for an interchromosomal matrix.")
parser.add_argument('--max_cluster_size',
metavar = 'MAX',
type = int,
action = 'store',
default = 1000,
help = "Skip read-clusters with more reads than MAX. (default 1000)")
parser.add_argument('--min_cluster_size',
metavar = 'MIN',
type = int,
action = 'store',
default = 2,
help = "Skip read-clusters with fewer reads than MIN. (default 2)")
parser.add_argument('--resolution',
metavar = 'INT',
type = int,
action = 'store',
default = 1000000,
help = "Contact matrix resolution in bp. (default 1000000 = 1 Mb)")
parser.add_argument('--downweighting',
metavar = 'DW',
action = 'store',
default = "none",
choices = ["none", "n_minus_one", "n_over_two"],
help = "Downweighting strategy")
parser.add_argument('--hicorrector',
metavar = "FILE",
action = 'store',
default = "/mnt/new-storage/Software/hicorrector/1.2/bin/ic",
help = "Path to hicorrector ic. (default /mnt/new-storage/Software/hicorrector/1.2/bin/ic)")
parser.add_argument('--iterations',
metavar = 'INT',
type = int,
action = 'store',
default = 100,
help = "Number of ICE iterations (default 100)")
return parser.parse_args()
if __name__ == "__main__":
main()