annotate gops_basecoverage.py @ 6:4d584cf5ced5 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
author devteam
date Mon, 13 Jun 2022 16:26:51 +0000
parents 37652c34b3bf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
1 #!/usr/bin/env python
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
2 """
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
3 Count total base coverage.
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
4
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
5 usage: %prog in_file out_file
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
6 -1, --cols1=N,N,N,N: Columns for start, end, strand in first file
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
7 """
5
37652c34b3bf planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
devteam
parents: 3
diff changeset
8 from __future__ import print_function
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
9
3
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
10 import fileinput
5
37652c34b3bf planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
devteam
parents: 3
diff changeset
11
37652c34b3bf planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
devteam
parents: 3
diff changeset
12 from bx.cookbook import doc_optparse
3
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
13 from bx.intervals.io import NiceReaderWrapper
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
14 from bx.intervals.operations.base_coverage import base_coverage
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
15 from bx.tabular.io import ParseError
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
16 from galaxy.tools.util.galaxyops import fail, parse_cols_arg, skipped
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
17
3
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
18
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
19 def main():
6
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
20 options, args = doc_optparse.parse(__doc__)
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
21 try:
6
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
22 chr_col_1, start_col_1, end_col_1, strand_col_1 = parse_cols_arg(options.cols1)
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
23 in_fname, out_fname = args
6
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
24 except Exception:
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
25 doc_optparse.exception()
3
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
26
6
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
27 g1 = NiceReaderWrapper(
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
28 fileinput.FileInput(in_fname),
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
29 chrom_col=chr_col_1,
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
30 start_col=start_col_1,
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
31 end_col=end_col_1,
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
32 strand_col=strand_col_1,
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
33 fix_strand=True
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
34 )
3
c929b6540d07 planemo upload commit 33927a87ba2eee9bf0ecdd376a66241b17b3d734
devteam
parents: 0
diff changeset
35
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
36 try:
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
37 bases = base_coverage(g1)
5
37652c34b3bf planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
devteam
parents: 3
diff changeset
38 except ParseError as exc:
6
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
39 fail("Invalid file format: %s" % str(exc))
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
40 out_file = open(out_fname, "w")
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
41 out_file.write("%s\n" % str(bases))
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
42 out_file.close()
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
43 if g1.skipped > 0:
6
4d584cf5ced5 planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit 200bd4645dd768eb6ee1aab7d181b76d34d13d4c
devteam
parents: 5
diff changeset
44 print(skipped(g1, filedesc=""))
5
37652c34b3bf planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tool_collections/gops/basecoverage commit cae3e05d02e60f595bb8b6d77a84f030e9bd1689
devteam
parents: 3
diff changeset
45
0
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
46
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
47 if __name__ == "__main__":
3755ee8a74d7 Imported from capsule None
devteam
parents:
diff changeset
48 main()