drep 4.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ #!python
2
+
3
+
4
+ ###############################################################################
5
+ #
6
+ # dRep - main program entry point
7
+ #
8
+ ###############################################################################
9
+
10
+ __author__ = "Matt Olm"
11
+ __license__ = "MIT"
12
+ __email__ = "mattolm@gmail.com"
13
+ __status__ = "Development"
14
+
15
+ import argparse
16
+ import os
17
+ import sys
18
+
19
+ if sys.version_info[0] < 3:
20
+ print('''
21
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22
+ !!! you're running dRep with python2 - you need python 3 !!!
23
+ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!''')
24
+ sys.exit(1)
25
+
26
+ import drep.argumentParser
27
+ from drep.controller import Controller
28
+
29
+ if __name__ == '__main__':
30
+ args = drep.argumentParser.parse_args(sys.argv[1:])
31
+ # do what you came here to do :)
32
+ Controller().parseArguments(args)
@@ -0,0 +1,140 @@
1
+ #!python
2
+
3
+ import os
4
+ import sys
5
+ import gzip
6
+ import textwrap
7
+ import argparse
8
+
9
+ def extract_bins(fasta, stb_file, out_base):
10
+ if (out_base != '') & (out_base[-1] != '/'):
11
+ out_base += '_'
12
+
13
+ # Make scaffold to bin dictionary
14
+ stb = {}
15
+ with open(stb_file) as stb_reader:
16
+ for line in stb_reader:
17
+ line = line.strip()
18
+
19
+ if line.startswith('#') or line.startswith('scaffold_name'):
20
+ continue
21
+
22
+ scaffold, bin = line.split('\t')[:2]
23
+ stb[scaffold.strip()] = bin.strip()
24
+
25
+ # Parse the FASTA file and write to bins
26
+ if fasta.endswith('.gz'):
27
+ open_func = gzip.open
28
+ mode = 'rt'
29
+ else:
30
+ open_func = open
31
+ mode = 'r'
32
+
33
+ with open_func(fasta, mode) as handle:
34
+ record_id = ''
35
+ record_seq = ''
36
+ for line in handle:
37
+ if line.startswith('>'):
38
+ if record_id and record_id in stb:
39
+ bin = stb[record_id]
40
+ with open(f"{out_base}{bin}.fa", 'a') as nw:
41
+ nw.write(f">{record_id}\n{record_seq}\n")
42
+ record_id = line[1:].strip().split(' ')[0]
43
+ record_seq = ''
44
+ else:
45
+ record_seq += line.strip()
46
+
47
+ # Write the last record
48
+ if record_id and record_id in stb:
49
+ bin = stb[record_id]
50
+ with open(f"{out_base}{bin}.fa", 'a') as nw:
51
+ nw.write(f">{record_id}\n{record_seq}\n")
52
+
53
+ import os
54
+ import gzip
55
+
56
+ def gen_stb(fastas):
57
+ if ((len(fastas) == 1) & (not fastas[0].endswith('.gz'))):
58
+ # See if this is a text file, not a fasta file
59
+ text_list = True
60
+ genomes = []
61
+ with open(fastas[0], 'r') as o:
62
+ for line in o.readlines():
63
+ if line.startswith('>'):
64
+ text_list = False
65
+ break
66
+ else:
67
+ genomes.append(line.strip())
68
+ if text_list:
69
+ print("Treating .fasta input as list")
70
+ fastas = genomes
71
+
72
+ stb = {}
73
+ for fasta in fastas:
74
+ bin = os.path.basename(fasta)
75
+ if fasta.endswith('.gz'):
76
+ open_func = gzip.open
77
+ mode = 'rt'
78
+ else:
79
+ open_func = open
80
+ mode = 'r'
81
+
82
+ with open_func(fasta, mode) as handle:
83
+ for line in handle:
84
+ if line.startswith('>'):
85
+ id = line[1:].strip().split(' ')[0]
86
+ stb[id] = bin
87
+
88
+ return stb
89
+
90
+
91
+ def print_stb(stb, output):
92
+ file = open(output,'w')
93
+ for key in sorted(stb, key=stb.get):
94
+ file.write("{0}\t{1}\n".format(key,stb[key]))
95
+ file.close()
96
+
97
+
98
+ class SmartFormatter(argparse.HelpFormatter):
99
+ def _split_lines(self, text, width):
100
+ if text.startswith('R|'):
101
+ return text[2:].splitlines()
102
+ # this is the RawTextHelpFormatter._split_lines
103
+ return argparse.HelpFormatter._split_lines(self, text, width)
104
+
105
+ if __name__ == '__main__':
106
+ parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
107
+ usage=textwrap.dedent('''\
108
+ \n
109
+ The program has two uses related to scaffold to bin (.stb) files.
110
+ .stb files should be tab-separated, with no header, and two columns: scaffold and bin
111
+
112
+ Use 1) Pass a list of genomes to generate a .stb file.
113
+
114
+ Example:
115
+ parse_stb.py --reverse -f dereplicate_genomes/* -o representitve_genomes.stb
116
+
117
+ Use 2) Pass a single .fasta file and a scaffold to bin file (.stb) to generate a number of
118
+ fasta files based on the .stb file.
119
+
120
+ Example:
121
+ parse_stb.py -f concat_genomes.fasta -s scaffold_to_bin.tsv -o genomeList_1
122
+ '''))
123
+
124
+ parser.add_argument('-s','--stb',help='scaffold to bin file')
125
+ parser.add_argument('-f','--fasta',help='fasta file to extract scaffolds from. Will treat as compressed if ends in .gz. This can also be a single text file with a genome on each line',nargs='*')
126
+ parser.add_argument('-o','--output',help='output base name', default = '')
127
+
128
+ parser.add_argument('--reverse',help='generate a stb from a list of genomes',\
129
+ action = "store_true")
130
+ args = parser.parse_args()
131
+
132
+ if args.reverse == False:
133
+ if len(args.fasta) != 1:
134
+ print("must give one and only one fasta file")
135
+ sys.exit()
136
+ extract_bins(args.fasta[0], args.stb, args.output)
137
+
138
+ if args.reverse == True:
139
+ stb = gen_stb(args.fasta)
140
+ print_stb(stb, args.output)
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: drep
3
+ Version: 4.0.2
4
+ Summary: De-replication of microbial genomes assembled from multiple samples
5
+ Home-page: https://github.com/MrOlm/drep
6
+ Author: Matt Olm
7
+ Author-email: mattolm@berkeley.edu
8
+ License: MIT
9
+ Requires-Dist: numpy
10
+ Requires-Dist: pandas
11
+ Requires-Dist: seaborn
12
+ Requires-Dist: matplotlib
13
+ Requires-Dist: biopython
14
+ Requires-Dist: scikit-learn
15
+ Requires-Dist: tqdm
16
+ Requires-Dist: setuptools
17
+ Requires-Dist: pytest
18
+ Dynamic: author
19
+ Dynamic: author-email
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: requires-dist
23
+ Dynamic: summary
@@ -0,0 +1,28 @@
1
+ drep/VERSION,sha256=xtP7BXsZjx0FY9QhjU42tI33UiUaq__njqYKrFpyx6I,6
2
+ drep/WorkDirectory.py,sha256=xMd7qrNmUXsPPiJXpKBJgnFMzYHP4nAyBL9vWpxK0bo,11616
3
+ drep/__init__.py,sha256=4579XfOUsiv6JlPzpU_fHU0iYApKaDSp17xqCmmqFKM,2846
4
+ drep/argumentParser.py,sha256=Ca3LSN9-5-49Ml_7XQkUiEJbaYmbKOdJMWi0cxiCq6k,18336
5
+ drep/controller.py,sha256=3yZ7MxHQoUUllZIhitRMhZXrTPftg3YEPlT60diTFmo,3334
6
+ drep/d_adjust.py,sha256=ZekouLh3ExONxeQ4D0RfybkZhmhc6j6CiTlcv3y34V0,9455
7
+ drep/d_analyze.py,sha256=YJ5ImCQ6NIS_WNS3Yr-1nvMniKTxfbDf52KOZGelZSs,50776
8
+ drep/d_bonus.py,sha256=UGnOHSxecSDoeMvk64XpNKTM7S4aoWaanchx_tzCEjY,13829
9
+ drep/d_choose.py,sha256=z-IJkpFoFISDJdtwXhvhPf01iXJu7xFinbWCHzcZH4c,11312
10
+ drep/d_evaluate.py,sha256=RjB4SOqyahWjCESFhuumcMHPq8zeOXfJlpDVFw_6FbA,14393
11
+ drep/d_filter.py,sha256=FfhpRGBSbltNHE7KrkzEguS27B4FW1BN0aExJnNRMJY,29271
12
+ drep/d_workflows.py,sha256=gmpjp9c2B_BhfsOPbD2P32l6yp9L2ZI8qJ551Wkv24k,4161
13
+ drep/d_cluster/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ drep/d_cluster/cluster_utils.py,sha256=yrQg-4V-bSltqwZhZhNdU_uBcvvol66wXGlIZXqr1bc,3977
15
+ drep/d_cluster/compare_utils.py,sha256=KtKTqXRQLobF4CIHoSJG8wmpdfsx3MFmof6TU_k3f_c,27590
16
+ drep/d_cluster/controller.py,sha256=gkdDwNkToc-TEbrRmPhzhCE0czssqeAKO999NYykNaw,9264
17
+ drep/d_cluster/external.py,sha256=uHb4GYJfwsDgzyNi76JlCQ5VJfsQZmiH0Mq2Ls6_S_g,26053
18
+ drep/d_cluster/greedy_clustering.py,sha256=61gb6dCP9FYEV6stWjSh6iFH26uSaMCwRJ9JLBQRGhg,6871
19
+ drep/d_cluster/parsers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ drep/d_cluster/union_find.py,sha256=rLO0BiXVY-VsrarzZ7h7GuSYdc0dvaae7Fg6ZIpx2Rw,19274
21
+ drep/d_cluster/utils.py,sha256=HsNJJ3A8uLvKaTm8iR2OTq5Sz24ENmvRUSqYejmnn7o,22507
22
+ drep-4.0.2.data/scripts/ScaffoldLevel_dRep.py,sha256=H3-TpjQkdgTCJmx080oGjmzpPsaLUQxPfHFuBOy-qVE,35201
23
+ drep-4.0.2.data/scripts/dRep,sha256=PHJCJBCsO31KYPIQYgTdmZ7CpILAQ5EJxFlxz7_zW3g,835
24
+ drep-4.0.2.data/scripts/parse_stb.py,sha256=d4eqJvx6M-skorqMypAo1jVjDomZPGNgTHZJZP8O3qo,4554
25
+ drep-4.0.2.dist-info/METADATA,sha256=cxjovehPCsHW6s5bL1sUPXu3lBRHvmrVmtcBUvpDGLA,558
26
+ drep-4.0.2.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
27
+ drep-4.0.2.dist-info/top_level.txt,sha256=St4866c-N05G5-o-ofs8yLmlWUBnX0lOFPZ7SB6h8Ls,5
28
+ drep-4.0.2.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ drep