Skip to content

Commit 999ed4e

Browse files
authored
Merge pull request #56 from ygidtu/dev
update to v0.0.8, fix --log, add conda config
2 parents 62db8e2 + c604415 commit 999ed4e

20 files changed

Lines changed: 186 additions & 240 deletions

docs/installation.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,49 @@
11

2-
## Install from source
2+
## Install with pypi, conda or docker
33

4-
download source code using git
4+
### via Conda
55
```bash
6+
conda install sashimi-py
7+
8+
# create conda env from local
9+
610
git clone from https://github.com/ygidtu/sashimipy sashimi
711
cd sashimi
12+
13+
conda create env -n sashimi meta.yaml
814
```
915

10-
### Run as command line tools
16+
### via PyPI
1117

1218
```bash
1319
pip install sashimi.py
20+
```
1421

15-
# or install from source
16-
python setup.py install
22+
### via Docker
1723

18-
sashimipy --help
24+
```bash
25+
docker pull ygidtu/sashimi
1926
```
2027

21-
or
28+
## Install from source
2229

30+
download source code using git
2331
```bash
24-
## via Conda
25-
conda install sashimi-py
32+
git clone from https://github.com/ygidtu/sashimipy sashimi
33+
cd sashimi
34+
```
2635

27-
## via Docker
28-
docker pull quay.io/biocontainers/sashimi-py
36+
### Run as command line tools
37+
38+
```bash
39+
## install from source
2940

30-
## via PyPI
3141
pip install sashimi.py
3242

43+
# or install from source
44+
python setup.py install
45+
46+
sashimipy --help
3347
```
3448

3549
### Run as script

meta.yaml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{% set name = "sashimi.py" %}
2+
{% set version = "0.0.8" %}
3+
4+
5+
package:
6+
name: sashimi-py
7+
version: {{ version }}
8+
9+
source:
10+
url: "https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz"
11+
sha256: 22d444d3ae5416ddaab3a20d2fa7e254edc00bbf22165edfdea22d328852dd43
12+
13+
build:
14+
noarch: python
15+
number: 0
16+
script: {{ PYTHON }} -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv
17+
18+
requirements:
19+
host:
20+
- python
21+
- wheel
22+
- setuptools
23+
- setuptools_scm
24+
- pip
25+
- filetype
26+
- pysam
27+
- pybigwig
28+
- hicmatrix
29+
- click-option-group
30+
run:
31+
- python
32+
- wheel
33+
- pysam
34+
- filetype
35+
- pybigwig
36+
- click-option-group
37+
- cairocffi
38+
- hicmatrix
39+
- samtools
40+
- tabix
41+
- matplotlib-base
42+
- seaborn-base
43+
- click
44+
- numpy
45+
- requests
46+
- xmltodict
47+
- pandas
48+
- loguru
49+
50+
test:
51+
imports:
52+
- sashimi
53+
54+
commands:
55+
- sashimipy --help
56+
57+
about:
58+
home: https://github.com/ygidtu/sashimi.py
59+
summary: "This is an pure Python version of sashimi plot"
60+
doc_url: https://sashimi.readthedocs.io/en/latest/
61+
license: BSD-3-Clause
62+
license_family: BSD
63+
license_file: LICENSE
64+
65+
extra:
66+
recipe-maintainers:
67+
- ygidtu

sashimi/base/CoordinateMap.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -218,17 +218,4 @@ def pep_to_cds(self, pep_start: int, pep_end: Optional[int] = None):
218218

219219

220220
if __name__ == '__main__':
221-
def test():
222-
cds = [(3216025, 3216968),
223-
(3421702, 3421901),
224-
(3670552, 3671348)]
225-
226-
coord = CoordinateMapper(cds, "+")
227-
domain_info = [(1, 3, "1XK-related protein 4;chain")]
228-
domain_coord = coord.pep_to_cds(1, 3)
229-
print(domain_coord.se)
230-
# [(3216025, 3216033)]
231-
232-
233-
test()
234221
pass

sashimi/base/Protein.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ def __init_protein__(self):
182182
)
183183

184184
for current_transcript_id in self.cds.keys():
185-
# print(current_transcript_id, len(self.cds[current_transcript_id]))
186185
current_pep = Uniprot(
187186
uniprot_id=current_transcript_id,
188187
cds_len=len(self.cds[current_transcript_id]),
@@ -227,9 +226,7 @@ def __init_protein__(self):
227226
min(map(lambda x: x.start, i)) for i in domain_list
228227
])
229228

230-
end_site = max([
231-
max(map(lambda x: x.end, i)) for i in domain_list
232-
])
229+
end_site = max([max(map(lambda x: x.end, i)) for i in domain_list])
233230

234231
protein_info[current_transcript_id].append(
235232
Transcript(
@@ -250,26 +247,4 @@ def __init_protein__(self):
250247

251248

252249
if __name__ == '__main__':
253-
def test():
254-
import pysam
255-
with pysam.Tabixfile("../../example/example.sorted.gtf.gz", 'r') as gtf_tabix:
256-
cds_test = CdsProtein.__re_iter_gtf__(
257-
gtf_tabix=gtf_tabix,
258-
chromosome='chr1',
259-
# transcript_id={'ENST00000421241'},
260-
transcript_id={'ENST00000477196'},
261-
gene_id={'ENSG00000131591'}
262-
)
263-
print(cds_test.pep)
264-
for transcript_id, domains in cds_test.pep.items():
265-
if len(domains) == 0:
266-
continue
267-
268-
for sub_domain in domains:
269-
print(transcript_id,
270-
sub_domain.gene,
271-
sub_domain.domain, sub_domain.exon_list)
272-
273-
274-
test()
275250
pass

sashimi/base/ReadDepth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,14 @@ def add_customized_junctions(self, other):
138138
return new_junctions_dict
139139

140140
def transform(self, log_trans: str):
141-
funcs = {"10": np.log10, "2": np.log2, "zscore": zscore}
141+
funcs = {"10": np.log10, "2": np.log2, "zscore": zscore, "e": np.log}
142142

143143
if log_trans in funcs.keys():
144144
if self.plus is not None:
145145
self.plus = funcs[log_trans](self.plus + 1)
146146

147147
if self.minus is not None:
148-
self.minus = -funcs[log_trans](np.abs(self.minus + 1))
148+
self.minus = funcs[log_trans](self.minus + 1)
149149

150150
def normalize(self, size_factor: float):
151151
self.plus = np.divide(self.plus, size_factor) # * 100

sashimi/base/pyUniprot.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -208,31 +208,4 @@ def __domain_info__(self):
208208

209209

210210
if __name__ == '__main__':
211-
def test():
212-
"""
213-
trans_id = 'ENST00000339381'
214-
trans_id_pep = Uniprot(uniprot_id=trans_id, cds_len=2010)
215-
216-
trans_id = 'ENST00000379319'
217-
trans_id_pep = Uniprot(uniprot_id=trans_id, cds_len=594)
218-
219-
trans_id = 'ENST00000486161'
220-
# # 5736 real, 4515 false
221-
trans_id_pep = Uniprot(uniprot_id=trans_id, cds_len=4515)
222-
223-
trans_id = 'ENST00000378891'
224-
trans_id_pep = Uniprot(uniprot_id=trans_id, cds_len=2085)
225-
226-
"""
227-
228-
trans_id = 'ENST00000351718'
229-
trans_id_pep = Uniprot(uniprot_id=trans_id, cds_len=3549)
230-
231-
print(trans_id_pep.guessed_id)
232-
print(trans_id_pep.domain)
233-
for i in trans_id_pep.domain:
234-
print(i.category, i.type, i.begin, i.end)
235-
236-
237-
test()
238211
pass

sashimi/cli.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from sashimi.file.ATAC import ATAC
2222
from sashimi.plot import Plot
2323

24-
__version__ = "0.0.7"
24+
__version__ = "0.0.8"
2525
__author__ = "ygidtu & Ran Zhou"
2626
__email__ = "ygidtu@gmail.com"
2727

@@ -556,8 +556,8 @@ def main(**kwargs):
556556
show_site_plot=kwargs["show_site"],
557557
strand_choice=kwargs["site_strand"],
558558
density_by_strand=kwargs["density_by_strand"],
559-
only_customized_junction=kwargs["only_customized_junction"]
560-
)
559+
only_customized_junction=kwargs["only_customized_junction"],
560+
log_trans=kwargs["log"])
561561
elif f.category != "atac":
562562
p.add_density(f.path,
563563
category=f.category,
@@ -572,7 +572,8 @@ def main(**kwargs):
572572
show_y_label=not kwargs["hide_y_label"],
573573
show_site_plot=kwargs["show_site"],
574574
strand_choice=kwargs["site_strand"],
575-
density_by_strand=kwargs["density_by_strand"],)
575+
density_by_strand=kwargs["density_by_strand"],
576+
log_trans=kwargs["log"])
576577
elif key == "heatmap":
577578
for f in process_file_list(kwargs[key], key):
578579
if barcodes and f.name in barcodes.keys() and f.category in ["bam", "atac"]:
@@ -599,7 +600,8 @@ def main(**kwargs):
599600
font_size=kwargs["font_size"],
600601
do_scale=kwargs["heatmap_scale"],
601602
vmin=kwargs["heatmap_vmin"],
602-
vmax=kwargs["heatmap_vmax"])
603+
vmax=kwargs["heatmap_vmax"],
604+
log_trans=kwargs["log"])
603605
elif f.category != "atac":
604606
p.add_heatmap(f.path,
605607
category=f.category,
@@ -617,7 +619,8 @@ def main(**kwargs):
617619
show_row_names=kwargs["show_row_names"],
618620
do_scale=kwargs["heatmap_scale"],
619621
vmin=kwargs["heatmap_vmin"],
620-
vmax=kwargs["heatmap_vmax"])
622+
vmax=kwargs["heatmap_vmax"],
623+
log_trans=kwargs["log"])
621624
elif key == "line":
622625
for f in process_file_list(kwargs[key], key):
623626
if barcodes and f.name in barcodes.keys() and f.category == "bam":
@@ -643,7 +646,8 @@ def main(**kwargs):
643646
n_y_ticks=kwargs["n_y_ticks"],
644647
show_legend=not kwargs["hide_legend"],
645648
legend_position=kwargs["legend_position"],
646-
legend_ncol=kwargs["legend_ncol"])
649+
legend_ncol=kwargs["legend_ncol"],
650+
log_trans=kwargs["log"])
647651
else:
648652
p.add_line(f.path,
649653
category=f.category,
@@ -658,7 +662,8 @@ def main(**kwargs):
658662
n_y_ticks=kwargs["n_y_ticks"],
659663
show_legend=not kwargs["hide_legend"],
660664
legend_position=kwargs["legend_position"],
661-
legend_ncol=kwargs["legend_ncol"])
665+
legend_ncol=kwargs["legend_ncol"],
666+
log_trans=kwargs["log"])
662667
elif key == "igv":
663668
for f in process_file_list(kwargs[key], "igv"):
664669
igv_features = {}
@@ -742,6 +747,7 @@ def main(**kwargs):
742747
included_junctions=included_junctions,
743748
n_jobs=kwargs.get("process", 1)
744749
)
750+
logger.info("DONE")
745751

746752

747753
if __name__ == '__main__':

sashimi/file/ATAC.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,4 @@ def load(self,
157157

158158

159159
if __name__ == '__main__':
160-
bam = ATAC.create("../../example/bams/sc.bam")
161-
bam.load(GenomicLoci("chr1", 1270656, 1284730, "+"), 10)
162-
163-
print(str(bam))
164160
pass

sashimi/file/Bam.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ def load(self,
124124
threshold: int = 0,
125125
reads1: Optional[bool] = None,
126126
required_strand: Optional[str] = None,
127-
log_trans: Optional[str] = None,
128127
**kwargs
129128
):
130129
"""
@@ -144,10 +143,8 @@ def load(self,
144143
:param threshold: minimums counts of the given splice junction for visualization
145144
:param reads1: None -> all reads, True -> only R1 kept; False -> only R2 kept
146145
:param required_strand: None -> all reads, else reads on specific strand
147-
:param log_trans: should one of {"10": np.log10, "2": np.log2}
148146
"""
149147
self.region = region
150-
self.log_trans = log_trans
151148
filtered_junctions = {}
152149

153150
spanned_junctions = kwargs.get("junctions", {})
@@ -296,17 +293,4 @@ def load(self,
296293

297294

298295
if __name__ == '__main__':
299-
bam = Bam.create(
300-
"../../example/bams/sc.bam",
301-
library="frf")
302-
bam.load(GenomicLoci("chr1", 1270656, 1284730, "+"), 10)
303-
304-
print(str(bam))
305-
print(bam.to_csv())
306-
print(max(bam.data.wiggle), min(bam.data.wiggle))
307-
print(bam.data.junctions_dict)
308-
print(max(bam.data.plus))
309-
print(min(bam.data.minus))
310-
print(max(bam.data.site_plus))
311-
print(min(bam.data.site_minus))
312296
pass

sashimi/file/BedGraph.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,4 @@ def load(self, region: GenomicLoci, **kwargs):
4747

4848

4949
if __name__ == "__main__":
50-
bw = Bedgraph.create("../../example/bedgraph/ENCFF260QGF_lung_filter.bedgraph.gz")
51-
bw.load(GenomicLoci("chr1", 120457967, 120459467, "+"))
52-
print(bw.data.wiggle)
5350
pass

0 commit comments

Comments
 (0)