Skip to content

Commit e76fcfb

Browse files
formatting
1 parent e13c52c commit e76fcfb

File tree

3 files changed

+34
-30
lines changed

3 files changed

+34
-30
lines changed

workflow/Snakefile

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,9 @@ container: "docker://continuumio/miniconda3"
2323

2424

2525
include: "rules/common.smk"
26-
27-
2826
include: "rules/ref.smk"
29-
30-
3127
include: "rules/trim.smk"
32-
33-
3428
include: "rules/align.smk"
35-
36-
3729
include: "rules/diffexp.smk"
3830

3931

workflow/scripts/count-matrix.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
import sys
2+
23
# logging
34
sys.stderr = open(snakemake.log[0], "w")
45

56
import pandas as pd
67

8+
79
def get_column(strandedness):
810
if pd.isnull(strandedness) or strandedness == "none":
9-
return 1 #non stranded protocol
11+
return 1 # non stranded protocol
1012
elif strandedness == "yes":
11-
return 2 #3rd column
13+
return 2 # 3rd column
1214
elif strandedness == "reverse":
13-
return 3 #4th column, usually for Illumina truseq
15+
return 3 # 4th column, usually for Illumina truseq
1416
else:
15-
raise ValueError(("'strandedness' column should be empty or have the "
16-
"value 'none', 'yes' or 'reverse', instead has the "
17-
"value {}").format(repr(strandedness)))
17+
raise ValueError(
18+
(
19+
"'strandedness' column should be empty or have the "
20+
"value 'none', 'yes' or 'reverse', instead has the "
21+
"value {}"
22+
).format(repr(strandedness))
23+
)
24+
1825

19-
counts = [pd.read_table(f, index_col=0, usecols=[0, get_column(strandedness)],
20-
header=None, skiprows=4)
21-
for f, strandedness in zip(snakemake.input, snakemake.params.strand)]
26+
counts = [
27+
pd.read_table(
28+
f, index_col=0, usecols=[0, get_column(strandedness)], header=None, skiprows=4
29+
)
30+
for f, strandedness in zip(snakemake.input, snakemake.params.strand)
31+
]
2232

2333
for t, sample in zip(counts, snakemake.params.samples):
2434
t.columns = [sample]
@@ -27,4 +37,4 @@ def get_column(strandedness):
2737
matrix.index.name = "gene"
2838
# collapse technical replicates
2939
matrix = matrix.groupby(matrix.columns, axis=1).sum()
30-
matrix.to_csv(snakemake.output[0], sep="\t")
40+
matrix.to_csv(snakemake.output[0], sep="\t")

workflow/scripts/gtf2bed.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import gffutils
22

3-
db = gffutils.create_db(snakemake.input[0],
4-
dbfn=snakemake.output.db,
5-
force=True,
6-
keep_order=True,
7-
merge_strategy='merge',
8-
sort_attribute_values=True,
9-
disable_infer_genes=True,
10-
disable_infer_transcripts=True)
3+
db = gffutils.create_db(
4+
snakemake.input[0],
5+
dbfn=snakemake.output.db,
6+
force=True,
7+
keep_order=True,
8+
merge_strategy="merge",
9+
sort_attribute_values=True,
10+
disable_infer_genes=True,
11+
disable_infer_transcripts=True,
12+
)
1113

12-
with open(snakemake.output.bed, 'w') as outfileobj:
13-
for tx in db.features_of_type('transcript', order_by='start'):
14-
bed = [s.strip() for s in db.bed12(tx).split('\t')]
14+
with open(snakemake.output.bed, "w") as outfileobj:
15+
for tx in db.features_of_type("transcript", order_by="start"):
16+
bed = [s.strip() for s in db.bed12(tx).split("\t")]
1517
bed[3] = tx.id
16-
outfileobj.write('{}\n'.format('\t'.join(bed)))
18+
outfileobj.write("{}\n".format("\t".join(bed)))

0 commit comments

Comments
 (0)