Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
1db4d16f
Commit
1db4d16f
authored
13 years ago
by
kohleman
Browse files
Options
Downloads
Patches
Plain Diff
initial checkin
SVN: 21383
parent
a75cd8fc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
deep_sequencing_unit/source/Python/concatenatePdfs.py
+70
-0
70 additions, 0 deletions
deep_sequencing_unit/source/Python/concatenatePdfs.py
with
70 additions
and
0 deletions
deep_sequencing_unit/source/Python/concatenatePdfs.py
0 → 100644
+
70
−
0
View file @
1db4d16f
#!/usr/bin/python
'''
Concatenates several pdfs in a given directory depending
on the lane number in the file name.
This number is defined as the last number in the file name
separated by
'
_
'
The concatenated file will be named:
flow_cell +
'
_
'
+ lane +
'
_quality.pdf
'
@author: Manuel Kohler
@copyright: ETH Zurich
@precondition: Working pdftk installation
'''
import
os
import
fnmatch
import
subprocess
from
optparse
import
OptionParser
PDFTK
=
'
/usr/local/dsu/pdftk-1.41/pdftk/pdftk
'
LANES
=
8
class
pdfList
(
list
):
def
__init__
(
self
,
lane
,
pdfs
=
[]):
list
.
__init__
([])
self
.
lane
=
lane
self
.
extend
(
pdfs
)
def
options
():
parser
=
OptionParser
()
parser
.
add_option
(
"
-p
"
,
"
--path
"
,
dest
=
"
path
"
,
action
=
"
store
"
,
type
=
"
string
"
,
help
=
"
Path of the fastq files
"
,
metavar
=
"
PATH
"
)
(
options
,
args
)
=
parser
.
parse_args
()
return
(
options
.
path
)
def
concatenatePdfs
(
file_list
,
lane
):
# take the first list element as a reference for the final pdf name
flow_cell
=
'
_
'
.
join
(
file_list
[
0
].
split
(
'
_
'
,
4
)[
0
:
4
])
print
(
flow_cell
)
new_name
=
flow_cell
+
'
_
'
+
lane
+
'
_quality.pdf
'
args
=
[
PDFTK
,
'
cat
'
,
'
output
'
,
new_name
]
[
args
.
insert
(
1
,
i
)
for
i
in
file_list
]
a
=
subprocess
.
Popen
(
args
)
a
.
wait
()
[
os
.
remove
(
file
)
for
file
in
file_list
]
def
createPdfList
(
lane
):
path
=
options
()
# create pdf list depending on lane
ll
=
'
lane
'
+
lane
vars
()[
ll
]
=
pdfList
(
lane
)
for
file
in
os
.
listdir
(
path
):
if
fnmatch
.
fnmatch
(
file
,
'
*.pdf
'
):
for
l
in
(
file
.
split
(
'
_
'
)[
4
]):
if
(
l
==
lane
):
(
vars
()[
ll
]).
append
(
file
)
vars
()[
ll
].
sort
()
return
(
vars
()[
ll
])
def
__main__
():
list_of_pdfs
=
[]
for
i
in
range
(
1
,
LANES
+
1
):
l
=
createPdfList
(
str
(
i
))
list_of_pdfs
.
append
(
l
)
[
concatenatePdfs
(
list_of_pdfs
[
i
],
list_of_pdfs
[
i
].
lane
)
for
i
in
range
(
len
(
list_of_pdfs
))]
print
(
"
DONE...
"
)
__main__
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment