cutehap 1.0.0__tar.gz

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.
cutehap-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 JiangTao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
cutehap-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,72 @@
1
+ Metadata-Version: 2.4
2
+ Name: cutehap
3
+ Version: 1.0.0
4
+ Summary: Haplotype-resolved genomic structural variation detection with cuteHap
5
+ Home-page: https://github.com/Meltpinkg/cuteHap
6
+ Author: Shuqi Cao
7
+ Author-email: sqcao@stu.hit.edu.cn
8
+ License: MIT
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Requires-Dist: scipy
12
+ Requires-Dist: pysam
13
+ Requires-Dist: Biopython
14
+ Requires-Dist: Cigar
15
+ Requires-Dist: numpy
16
+ Requires-Dist: Cython
17
+ Dynamic: author
18
+ Dynamic: author-email
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: home-page
22
+ Dynamic: license
23
+ Dynamic: license-file
24
+ Dynamic: requires-dist
25
+ Dynamic: summary
26
+
27
+ # cuteHap
28
+
29
+ A haplotype-resolved SV detector in phased long read sequencing data.
30
+
31
+ ---
32
+ ### Installation
33
+ We recommand the installation via conda or pip:
34
+ ```
35
+ The installation via conda and pypi is now in construction.
36
+ ```
37
+ Alternatively, installing from source with:
38
+ ```
39
+ git clone https://github.com/Meltpinkg/cuteHap.git
40
+ cd cuteHap
41
+ CFLAGS="-std=c99" python setup.py install
42
+ ```
43
+
44
+ ---
45
+ ### Introduction
46
+ cuteHap detects germline or mosaic structural variations (SVs) through phased long reads sequencing alignments.
47
+
48
+ ---
49
+ ### Dependence
50
+
51
+ 1. python3
52
+ 2. scipy
53
+ 2. pysam
54
+ 3. Biopython
55
+ 4. cigar
56
+ 5. numpy
57
+ 6. Cython
58
+
59
+ ---
60
+ ### Quick Start
61
+ ```
62
+ cuteHap <phased.bam> <reference.fa> <output.vcf> <workdir>
63
+ ```
64
+
65
+ ---
66
+ ### Changelog
67
+ cuteHap (v1.0.0)
68
+ 1. the initial version of cuteHap
69
+
70
+ ---
71
+ ### Contact
72
+ For advising, bug reporting and requiring help, please post on [Github Issue](https://github.com/Meltpinkg/cuteHap/issues) or contact sqcao@stu.hit.edu.cn.
@@ -0,0 +1,46 @@
1
+ # cuteHap
2
+
3
+ A haplotype-resolved SV detector in phased long read sequencing data.
4
+
5
+ ---
6
+ ### Installation
7
+ We recommand the installation via conda or pip:
8
+ ```
9
+ The installation via conda and pypi is now in construction.
10
+ ```
11
+ Alternatively, installing from source with:
12
+ ```
13
+ git clone https://github.com/Meltpinkg/cuteHap.git
14
+ cd cuteHap
15
+ CFLAGS="-std=c99" python setup.py install
16
+ ```
17
+
18
+ ---
19
+ ### Introduction
20
+ cuteHap detects germline or mosaic structural variations (SVs) through phased long reads sequencing alignments.
21
+
22
+ ---
23
+ ### Dependence
24
+
25
+ 1. python3
26
+ 2. scipy
27
+ 2. pysam
28
+ 3. Biopython
29
+ 4. cigar
30
+ 5. numpy
31
+ 6. Cython
32
+
33
+ ---
34
+ ### Quick Start
35
+ ```
36
+ cuteHap <phased.bam> <reference.fa> <output.vcf> <workdir>
37
+ ```
38
+
39
+ ---
40
+ ### Changelog
41
+ cuteHap (v1.0.0)
42
+ 1. the initial version of cuteHap
43
+
44
+ ---
45
+ ### Contact
46
+ For advising, bug reporting and requiring help, please post on [Github Issue](https://github.com/Meltpinkg/cuteHap/issues) or contact sqcao@stu.hit.edu.cn.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
cutehap-1.0.0/setup.py ADDED
@@ -0,0 +1,29 @@
1
+ # coding=utf-8
2
+
3
+ from setuptools import setup, find_packages
4
+ from Cython.Build import cythonize
5
+
6
+ with open('README.md') as f:
7
+ readme = f.read()
8
+
9
+ cython_extensions = cythonize("src/cuteHap/*.pyx")
10
+
11
+ setup(
12
+ name = "cutehap",
13
+ version = "1.0.0",
14
+ description = "Haplotype-resolved genomic structural variation detection with cuteHap",
15
+ author = "Shuqi Cao",
16
+ author_email = "sqcao@stu.hit.edu.cn",
17
+ url = "https://github.com/Meltpinkg/cuteHap",
18
+ license = "MIT",
19
+ packages = find_packages("src"),
20
+ package_dir = {"": "src"},
21
+ data_files = [("", ["LICENSE"])],
22
+ scripts=['src/cuteHap/cuteHap'],
23
+ # long_description = LONG_DESCRIPTION,
24
+ long_description = readme,
25
+ long_description_content_type = 'text/markdown',
26
+ zip_safe = False,
27
+ install_requires = ['scipy', 'pysam', 'Biopython', 'Cigar', 'numpy', 'Cython'],
28
+ ext_modules=cython_extensions
29
+ )
File without changes
@@ -0,0 +1,151 @@
1
+ from string import Template
2
+ import tempfile
3
+ import subprocess, signal, logging, os, stat, sys
4
+
5
+ class Alarm(Exception):
6
+ pass
7
+
8
+ def alarm_handler(signum, frame):
9
+ raise Alarm
10
+
11
+ def setupLogging(debug=False):
12
+ logLevel = logging.DEBUG if debug else logging.INFO
13
+ logFormat = "%(asctime)s [%(levelname)s] %(message)s"
14
+ logging.basicConfig( stream=sys.stderr, level=logLevel, format=logFormat )
15
+ logging.info("Running %s" % " ".join(sys.argv))
16
+
17
+ def exe(cmd, timeout=-1):
18
+ """
19
+ Executes a command through the shell.
20
+ timeout in minutes! so 1440 mean is 24 hours.
21
+ -1 means never
22
+ """
23
+ proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, \
24
+ stderr=subprocess.STDOUT, close_fds=True,\
25
+ preexec_fn=os.setsid)
26
+ signal.signal(signal.SIGALRM, alarm_handler)
27
+ if timeout > 0:
28
+ signal.alarm(int(timeout*60))
29
+ try:
30
+ stdoutVal, stderrVal = proc.communicate()
31
+ signal.alarm(0) # reset the alarm
32
+ except Alarm:
33
+ logging.error(("Command was taking too long. "
34
+ "Automatic Timeout Initiated after %d" % (timeout)))
35
+ os.killpg(proc.pid, signal.SIGTERM)
36
+ proc.kill()
37
+ return 214,None,None
38
+
39
+ retCode = proc.returncode
40
+ return retCode,stdoutVal,stderrVal
41
+
42
+ class Command():
43
+ def __init__(self, cmd, jobname, stdout, stderr):
44
+ self.cmd = cmd
45
+ self.jobname = jobname
46
+ self.stdout = stdout
47
+ self.stderr = stderr
48
+
49
+ def asDict(self):
50
+ return {"CMD":self.cmd, "JOBNAME":self.jobname, \
51
+ "STDOUT":self.stdout, "STDERR":self.stderr}
52
+
53
+ class CommandRunner():
54
+ """
55
+ Uses a command template to run stuff. This is helpful for cluster commands
56
+ and chunking several commands together
57
+ """
58
+ def __init__(self, template=None, njobs=0):
59
+ """
60
+ template: a string that will become the template for submitting to your cluster:
61
+ #you can also go ahead and specify a string.Template
62
+ default is to not submit to your cluster
63
+ ${CMD} > ${STDOUT} 2> ${STDERR}
64
+ njobs: (0)
65
+ for clumping commands together and submitting them in a script
66
+ """
67
+ if template is None:
68
+ template = "${CMD} > ${STDOUT} 2> ${STDERR}"
69
+ self.runType = "Running"
70
+ else:
71
+ self.runType = "Submitting"
72
+ self.template = Template(template)
73
+ self.njobs = njobs
74
+
75
+ def __call__(self, cmds, wDir = None, id = None):
76
+ """
77
+ Executes Commands - can either be a list or a single Command
78
+ wDir is the working directory where chunk scripts will be written
79
+ if id is None a random identifier will be applied when chunking
80
+ """
81
+ if wDir is None:
82
+ wDir = "./"
83
+
84
+ if type(cmds) != list:
85
+ cmd = self.buildCommand(cmds)
86
+ return exe(cmd)
87
+
88
+ if self.njobs == 0:
89
+ outRet = []
90
+ for c in cmds:
91
+ outRet.append(exe(self.buildCommand(c)))
92
+ return outRet
93
+
94
+ if id is None:
95
+ id = tempfile.mkstemp(dir=wDir)[1]
96
+
97
+ outputRet =[]
98
+ for chunk, commands in enumerate( partition(cmds, self.njobs) ):
99
+ outScript = open(os.path.join(wDir, "%s_chunk%d.sh" % (id, chunk)),'w')
100
+ outScript.write("#!/bin/bash\n\n")
101
+ for c in commands:
102
+ outScript.write(c.cmd+"\n")
103
+ outScript.close()
104
+ #Add executeable
105
+ existing_permissions = stat.S_IMODE(os.stat(outScript.name).st_mode)
106
+ if not os.access(outScript.name, os.X_OK):
107
+ new_permissions = existing_permissions | stat.S_IXUSR
108
+ os.chmod(outScript.name, new_permissions)
109
+
110
+ submit = Command(outScript.name, \
111
+ id + "_chunk%d" % chunk, \
112
+ os.path.join(wDir, id + ("_chunk%d.out" % chunk)), \
113
+ os.path.join(wDir, id + ("_chunk%d.err" % chunk)))
114
+ cmd = self.buildCommand(submit)
115
+ outputRet.append(exe(cmd))
116
+
117
+ return outputRet
118
+
119
+ def checkTemplate(self):
120
+ """
121
+ Checks that my template works okay
122
+ """
123
+ temp.update({"CMD":"test", \
124
+ "STDOUT":"testo", \
125
+ "STDERR":"teste", \
126
+ "JOBNAME":"testn"})
127
+ try:
128
+ w = self.template.substitute(temp)
129
+ except KeyError:
130
+ logging.error("Your submission template is invalid ")
131
+ sys.exit(1)
132
+
133
+ def buildCommand(self, cmdSetup):
134
+ """
135
+ substitutes a template with a Command
136
+ """
137
+ return self.template.substitute(cmdSetup.asDict())
138
+
139
+ def partition(n,m):
140
+ """
141
+ Helper function. splits list n into m partitions
142
+ """
143
+ p = map(lambda x: list(), range(m))
144
+ index = 0
145
+ for item in n:
146
+ p[index].append(item)
147
+ if index < m-1:
148
+ index += 1
149
+ else:
150
+ index = 0
151
+ return filter(lambda x: len(x)>0, p)
File without changes