simplesam 0.1.4.0__tar.gz → 0.1.4.2__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.
@@ -0,0 +1,34 @@
1
+ name: Package Builds
2
+ on: push
3
+
4
+ jobs:
5
+ build-n-publish:
6
+ name: Build and publish packages to PyPI and TestPyPI
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - name: checkout
11
+ uses: actions/checkout@v3
12
+ with:
13
+ persist-credentials: false
14
+ fetch-depth: 0
15
+
16
+ - name: setup python
17
+ uses: actions/setup-python@v4
18
+ with:
19
+ python-version: 3.9
20
+
21
+ - name: build package
22
+ run: pipx run build
23
+
24
+ - name: Publish to test PyPI
25
+ uses: pypa/gh-action-pypi-publish@release/v1
26
+ with:
27
+ password: ${{ secrets.test_pypi_password }}
28
+ repository_url: https://test.pypi.org/legacy/
29
+
30
+ - name: Publish to tagged release to PyPI
31
+ if: startsWith(github.ref, 'refs/tags')
32
+ uses: pypa/gh-action-pypi-publish@release/v1
33
+ with:
34
+ password: ${{ secrets.pypi_password }}
@@ -0,0 +1,58 @@
1
+ name: Tests
2
+
3
+ # Controls when the action will run.
4
+ on:
5
+ push:
6
+ branches:
7
+ - master
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ${{ matrix.os }}
13
+
14
+ strategy:
15
+ fail-fast: false
16
+ max-parallel: 10
17
+ matrix:
18
+ python-version: ['3.13', '3.12', '3.11', '3.10', '3.9']
19
+ os: [ubuntu-latest, macos-latest]
20
+ exclude:
21
+ # mac os: exclude all but the last two (available) python releases
22
+ - os: macos-latest
23
+ python-version: 3.11
24
+ - os: macos-latest
25
+ python-version: 3.10
26
+ - os: macos-latest
27
+ python-version: 3.9
28
+
29
+ steps:
30
+ - name: checkout
31
+ uses: actions/checkout@v3.1.0
32
+ with:
33
+ persist-credentials: false
34
+ fetch-depth: 0
35
+
36
+ - name: setup python
37
+ uses: actions/setup-python@v4.3.0
38
+ with:
39
+ python-version: ${{ matrix.python }}
40
+
41
+
42
+ - name: set up virtual env
43
+ run: |
44
+ python3 -m venv venv
45
+ source venv/bin/activate
46
+ echo PATH=$PATH >> $GITHUB_ENV
47
+
48
+ - name: upgrade pip
49
+ run: python3 -m pip install --upgrade pip
50
+
51
+ - name: install pytest
52
+ run: python3 -m pip install pytest
53
+
54
+ - name: install package from current branch
55
+ run: python3 -m pip install .
56
+
57
+ - name: run tests
58
+ run: pytest --doctest-modules
@@ -0,0 +1,48 @@
1
+ # sphinx build folder
2
+ _build
3
+
4
+ # Compiled source #
5
+ ###################
6
+ *.com
7
+ *.class
8
+ *.dll
9
+ *.exe
10
+ *.o
11
+ *.so
12
+
13
+ # Packages #
14
+ ############
15
+ # it's better to unpack these files and commit the raw source
16
+ # git has its own built in compression methods
17
+ *.7z
18
+ *.dmg
19
+ *.gz
20
+ *.iso
21
+ *.jar
22
+ *.rar
23
+ *.tar
24
+ *.zip
25
+
26
+ # Logs and databases #
27
+ ######################
28
+ *.log
29
+ *.sql
30
+ *.sqlite
31
+
32
+ # OS generated files #
33
+ ######################
34
+ .DS_Store?
35
+ ehthumbs.db
36
+ Icon?
37
+ Thumbs.db
38
+
39
+ # Editor backup files #
40
+ #######################
41
+ *~
42
+
43
+ # Python #
44
+ venv
45
+ *.egg
46
+ *.pyc
47
+ *.egg-info*
48
+ build
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at mdshw5@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
File without changes
@@ -1,22 +1,28 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: simplesam
3
- Version: 0.1.4.0
3
+ Version: 0.1.4.2
4
4
  Summary: Simple pure Python SAM parser and objects for working with SAM records
5
5
  Home-page: http://mattshirley.com
6
6
  Author: Matthew Shirley
7
7
  Author-email: mdshw5@gmail.com
8
8
  License: MIT
9
- Platform: UNKNOWN
10
- Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Development Status :: 5 - Production/Stable
11
10
  Classifier: License :: OSI Approved :: MIT License
12
11
  Classifier: Environment :: Console
13
12
  Classifier: Intended Audience :: Science/Research
14
13
  Classifier: Natural Language :: English
15
14
  Classifier: Operating System :: Unix
16
15
  Classifier: Programming Language :: Python :: 2.7
17
- Classifier: Programming Language :: Python :: 3.4
16
+ Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
19
18
  License-File: LICENSE
20
-
21
- UNKNOWN
22
-
19
+ Requires-Dist: six
20
+ Requires-Dist: ordereddict
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: home-page
25
+ Dynamic: license
26
+ Dynamic: license-file
27
+ Dynamic: requires-dist
28
+ Dynamic: summary
@@ -1,5 +1,6 @@
1
1
  [![PyPI](https://img.shields.io/pypi/v/simplesam.svg?)](https://pypi.python.org/pypi/simplesam)
2
- [![Build Status](https://travis-ci.com/mdshw5/simplesam.svg?branch=master)](https://travis-ci.com/mdshw5/simplesam)
2
+ [![Tests](https://github.com/mdshw5/simplesam/actions/workflows/tests.yml/badge.svg)](https://github.com/mdshw5/simplesam/actions/workflows/tests.yml)
3
+ [![Package Builds](https://github.com/mdshw5/simplesam/actions/workflows/deploy.yml/badge.svg)](https://github.com/mdshw5/simplesam/actions/workflows/deploy.yml)
3
4
  [![Documentation Status](https://readthedocs.org/projects/simplesam/badge/?version=latest)](http://simplesam.readthedocs.io/en/latest/?badge=latest)
4
5
 
5
6
  # Simple SAM parsing
@@ -117,3 +118,27 @@ Write SAM files from `Sam` objects to stdout (allows `samtools view` compression
117
118
  ```bash
118
119
  $ python my_script_that_uses_simplesam.py | samtools view -hbo test.bam
119
120
  ```
121
+
122
+ # Example scripts
123
+ An example script [`pileup.py`](https://github.com/mdshw5/simplesam/blob/master/scripts/pileup.py) is installed with this module.
124
+ This script will generate an output that is similar to `samtools pileup` with the addition of several optional columns that summarize
125
+ counts for individual nucleotides (ACTGN) and deletions with respect to the reference (-). This script leverages the `Sam.gapped()` and
126
+ `Sam.parse_md()` methods to reconstruct position-specific counts from SAM alignment records.
127
+
128
+ ```bash
129
+ $ pileup.py -h
130
+ usage: pileup [-h] [--version] [-c] [-i STATS] bam pileup
131
+
132
+ generate a simple pileup-like file from a sorted/indexed BAM file
133
+
134
+ positional arguments:
135
+ bam sorted/indexed BAM file
136
+ pileup pileup output file
137
+
138
+ optional arguments:
139
+ -h, --help show this help message and exit
140
+ --version show program's version number and exit
141
+ -c, --counts display counts for A/C/T/G/N/- separately (default: False)
142
+ -i STATS, --stats STATS
143
+ tabulate mismatches to output file
144
+ ```
File without changes
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line.
5
+ SPHINXOPTS =
6
+ SPHINXBUILD = python -msphinx
7
+ SPHINXPROJ = simplesam
8
+ SOURCEDIR = .
9
+ BUILDDIR = _build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,179 @@
1
+ # -*- coding: utf-8 -*-
2
+ #
3
+ # simplesam documentation build configuration file, created by
4
+ # sphinx-quickstart on Mon Jul 17 10:55:40 2017.
5
+ #
6
+ # This file is execfile()d with the current directory set to its
7
+ # containing dir.
8
+ #
9
+ # Note that not all possible configuration values are present in this
10
+ # autogenerated file.
11
+ #
12
+ # All configuration values have a default; values that are commented out
13
+ # serve to show the default.
14
+
15
+ # If extensions (or modules to document with autodoc) are in another directory,
16
+ # add these directories to sys.path here. If the directory is relative to the
17
+ # documentation root, use os.path.abspath to make it absolute, like shown here.
18
+ #
19
+ # import os
20
+ # import sys
21
+ # sys.path.insert(0, os.path.abspath('.'))
22
+
23
+
24
+ # -- General configuration ------------------------------------------------
25
+
26
+ # If your documentation needs a minimal Sphinx version, state it here.
27
+ #
28
+ # needs_sphinx = '1.0'
29
+
30
+ # Add any Sphinx extension module names here, as strings. They can be
31
+ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32
+ # ones.
33
+ extensions = ['sphinx.ext.autodoc',
34
+ 'sphinx.ext.viewcode']
35
+
36
+ # Add any paths that contain templates here, relative to this directory.
37
+ templates_path = ['_templates']
38
+
39
+ # The suffix(es) of source filenames.
40
+ # You can specify multiple suffix as a list of string:
41
+ #
42
+ # source_suffix = ['.rst', '.md']
43
+ source_suffix = '.rst'
44
+
45
+ # The master toctree document.
46
+ master_doc = 'index'
47
+
48
+ # General information about the project.
49
+ project = u'simplesam'
50
+ copyright = u'2017, Matt Shirley'
51
+ author = u'Matt Shirley'
52
+
53
+ # The version info for the project you're documenting, acts as replacement for
54
+ # |version| and |release|, also used in various other places throughout the
55
+ # built documents.
56
+ #
57
+ # The short X.Y version.
58
+ version = u'0.0.5'
59
+ # The full version, including alpha/beta/rc tags.
60
+ release = u'0.0.5'
61
+
62
+ # The language for content autogenerated by Sphinx. Refer to documentation
63
+ # for a list of supported languages.
64
+ #
65
+ # This is also used if you do content translation via gettext catalogs.
66
+ # Usually you set "language" from the command line for these cases.
67
+ language = None
68
+
69
+ # List of patterns, relative to source directory, that match files and
70
+ # directories to ignore when looking for source files.
71
+ # This patterns also effect to html_static_path and html_extra_path
72
+ exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
73
+
74
+ # The name of the Pygments (syntax highlighting) style to use.
75
+ pygments_style = 'sphinx'
76
+
77
+ # If true, `todo` and `todoList` produce output, else they produce nothing.
78
+ todo_include_todos = False
79
+
80
+
81
+ # -- Options for HTML output ----------------------------------------------
82
+
83
+ # The theme to use for HTML and HTML Help pages. See the documentation for
84
+ # a list of builtin themes.
85
+ #
86
+ html_theme = 'alabaster'
87
+
88
+ html_theme_options = {
89
+ 'github_button': True,
90
+ 'github_user': 'mdshw5',
91
+ 'github_repo': 'simplesam',
92
+ 'github_type': 'star',
93
+ 'font_family': "Georgia, 'goudy old style', 'minion pro', 'bell mt', 'Hiragino Mincho Pro', serif",
94
+ }
95
+ # Theme options are theme-specific and customize the look and feel of a theme
96
+ # further. For a list of options available for each theme, see the
97
+ # documentation.
98
+ #
99
+ # html_theme_options = {}
100
+
101
+ # Add any paths that contain custom static files (such as style sheets) here,
102
+ # relative to this directory. They are copied after the builtin static files,
103
+ # so a file named "default.css" will overwrite the builtin "default.css".
104
+ html_static_path = ['_static']
105
+
106
+ # Custom sidebar templates, must be a dictionary that maps document names
107
+ # to template names.
108
+ #
109
+ # This is required for the alabaster theme
110
+ # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
111
+ html_sidebars = {
112
+ '**': [
113
+ 'about.html',
114
+ 'navigation.html',
115
+ 'relations.html', # needs 'show_related': True theme option to display
116
+ 'searchbox.html',
117
+ 'donate.html',
118
+ ]
119
+ }
120
+
121
+
122
+ # -- Options for HTMLHelp output ------------------------------------------
123
+
124
+ # Output file base name for HTML help builder.
125
+ htmlhelp_basename = 'simplesamdoc'
126
+
127
+
128
+ # -- Options for LaTeX output ---------------------------------------------
129
+
130
+ latex_elements = {
131
+ # The paper size ('letterpaper' or 'a4paper').
132
+ #
133
+ # 'papersize': 'letterpaper',
134
+
135
+ # The font size ('10pt', '11pt' or '12pt').
136
+ #
137
+ # 'pointsize': '10pt',
138
+
139
+ # Additional stuff for the LaTeX preamble.
140
+ #
141
+ # 'preamble': '',
142
+
143
+ # Latex figure (float) alignment
144
+ #
145
+ # 'figure_align': 'htbp',
146
+ }
147
+
148
+ # Grouping the document tree into LaTeX files. List of tuples
149
+ # (source start file, target name, title,
150
+ # author, documentclass [howto, manual, or own class]).
151
+ latex_documents = [
152
+ (master_doc, 'simplesam.tex', u'simplesam Documentation',
153
+ u'Matt Shirley', 'manual'),
154
+ ]
155
+
156
+
157
+ # -- Options for manual page output ---------------------------------------
158
+
159
+ # One entry per manual page. List of tuples
160
+ # (source start file, name, description, authors, manual section).
161
+ man_pages = [
162
+ (master_doc, 'simplesam', u'simplesam Documentation',
163
+ [author], 1)
164
+ ]
165
+
166
+
167
+ # -- Options for Texinfo output -------------------------------------------
168
+
169
+ # Grouping the document tree into Texinfo files. List of tuples
170
+ # (source start file, target name, title, author,
171
+ # dir menu entry, description, category)
172
+ texinfo_documents = [
173
+ (master_doc, 'simplesam', u'simplesam Documentation',
174
+ author, 'simplesam', 'One line description of project.',
175
+ 'Miscellaneous'),
176
+ ]
177
+
178
+
179
+
@@ -0,0 +1,20 @@
1
+ Simplesam
2
+ =========
3
+ Simple pure Python SAM parser and objects for working with SAM records
4
+
5
+ .. toctree::
6
+ :maxdepth: 2
7
+
8
+ index
9
+
10
+ .. automodule:: simplesam
11
+ :members:
12
+ :special-members:
13
+
14
+
15
+ Indices and tables
16
+ ==================
17
+
18
+ * :ref:`genindex`
19
+ * :ref:`modindex`
20
+ * :ref:`search`
@@ -0,0 +1,106 @@
1
+ #!/usr/bin/env python
2
+
3
+ import sys
4
+ import argparse
5
+ try:
6
+ from importlib.metadata import version
7
+ except ImportError:
8
+ import pkg_resources
9
+ version = lambda name: pkg_resources.get_distribution(name).version
10
+
11
+ __version__ = "unknown"
12
+ try:
13
+ __version__ = version("simplesam")
14
+ except Exception:
15
+ pass
16
+
17
+ from collections import deque
18
+ from collections import Counter
19
+ from collections import OrderedDict
20
+
21
+ class Extractor(OrderedDict):
22
+
23
+ def __missing__(self, pos):
24
+ value = (self.sam, deque(), deque())
25
+ self[pos] = value
26
+ return value
27
+
28
+ def update(self, sam, min_qual):
29
+ self.sam = sam
30
+ g = sam.pos
31
+ for i, (seq, qual) in enumerate(zip(sam.gapped('seq', '-'), sam.gapped('qual', '~'))):
32
+ if qual > min_qual:
33
+ self[g + i][1].append(seq)
34
+ self[g + i][2].append(qual)
35
+
36
+ def clear(self, stop=None):
37
+ for pos in sorted(k for k in self.keys() if stop is not None and k < stop):
38
+ sam, seq, qual = self.pop(pos)
39
+ ref = sam.parse_md()[sam.index_of(pos)]
40
+ try:
41
+ s, q = zip(*[(s, q) for s, q in zip(seq, qual) if s != ref])
42
+ except ValueError:
43
+ s, q = ([], [])
44
+ yield (sam.rname, str(pos), ref, str(len(seq) - len(s)), str(len(s)), ''.join(s), ''.join(q))
45
+
46
+
47
+ def pileup(args):
48
+ from simplesam import Reader
49
+
50
+ e = Extractor()
51
+ bases = ('A', 'C', 'T', 'G', 'N', '-')
52
+ stats = dict([('A', Counter()), ('C', Counter()), ('T', Counter()), ('G', Counter()), ('N', Counter()), ('-', Counter())])
53
+ with Reader(args.bam) as bam:
54
+ for read in bam:
55
+ if not read.mapped:
56
+ continue
57
+ if read.duplicate:
58
+ continue
59
+ if read.secondary:
60
+ continue
61
+ for line in e.clear(stop=read.pos):
62
+ if args.counts:
63
+ args.pileup.write('\t'.join(line) + '\t' + '\t'.join([str(line[5].count(c)) for c in bases]) + '\n')
64
+ else:
65
+ args.pileup.write('\t'.join(line) + '\n')
66
+ if args.stats:
67
+ stats[line[2]][line[2]] += int(line[3])
68
+ stats[line[2]].update(line[5])
69
+ e.update(read, '!')
70
+
71
+ for line in e.clear():
72
+ if args.counts:
73
+ args.pileup.write('\t'.join(line) + '\t' + '\t'.join([str(line[5].count(c)) for c in bases]) + '\n')
74
+ else:
75
+ args.pileup.write('\t'.join(line) + '\n')
76
+ if args.stats:
77
+ stats[line[2]][line[2]] += int(line[3])
78
+ stats[line[2]].update(line[5])
79
+
80
+ if args.stats:
81
+ for ref, counts in sorted(stats.items()):
82
+ for base in bases:
83
+ ref_count = counts[ref]
84
+ base_count = counts[base]
85
+ try:
86
+ percent_base = base_count / sum(counts.values())
87
+ except ZeroDivisionError:
88
+ percent_base = 0.
89
+ args.stats.write('{ref}\t{base}\t{ref_count}\t{base_count}\t{percent_base:.4%}\n'.format(**locals()))
90
+
91
+
92
+ def main():
93
+ parser = argparse.ArgumentParser(prog='pileup', description="generate a simple pileup-like file from a sorted/indexed BAM file")
94
+ parser.add_argument('--version', action='version', version="%(prog)s version {0}".format(__version__))
95
+
96
+ parser.add_argument('bam', type=argparse.FileType('r'), help="sorted/indexed BAM file ")
97
+ parser.add_argument('pileup', type=argparse.FileType('w'), help="pileup output file")
98
+ parser.add_argument('-c', '--counts', action='store_true', default=False, help="display counts for A/C/T/G/N/- separately (default: %(default)s)")
99
+ parser.add_argument('-i', '--stats', type=argparse.FileType('w'), help="tabulate mismatches to output file")
100
+ parser.set_defaults(func=pileup)
101
+
102
+ args = parser.parse_args()
103
+ args.func(args)
104
+
105
+ if __name__ == "__main__":
106
+ main()
File without changes
@@ -1,33 +1,27 @@
1
1
  from setuptools import setup
2
2
  import os.path
3
3
 
4
-
5
- def get_version(string):
6
- """ Parse the version number variable __version__ from a script. """
7
- import re
8
- version_re = r"^__version__ = ['\"]([^'\"]*)['\"]"
9
- version_str = re.search(version_re, string, re.M).group(1)
10
- return version_str
11
-
12
4
  setup(
13
5
  name='simplesam',
14
- version=get_version(open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'simplesam.py')).read()),
6
+ use_scm_version={"local_scheme": "no-local-version"},
7
+ setup_requires=['setuptools_scm'],
15
8
  author='Matthew Shirley',
16
9
  author_email='mdshw5@gmail.com',
17
10
  url='http://mattshirley.com',
18
11
  description='Simple pure Python SAM parser and objects for working with SAM records',
19
12
  license='MIT',
20
13
  classifiers=[
21
- "Development Status :: 3 - Alpha",
14
+ "Development Status :: 5 - Production/Stable",
22
15
  "License :: OSI Approved :: MIT License",
23
16
  "Environment :: Console",
24
17
  "Intended Audience :: Science/Research",
25
18
  "Natural Language :: English",
26
19
  "Operating System :: Unix",
27
20
  "Programming Language :: Python :: 2.7",
28
- "Programming Language :: Python :: 3.4",
21
+ "Programming Language :: Python :: 3.10",
29
22
  "Topic :: Scientific/Engineering :: Bio-Informatics",
30
23
  ],
31
24
  py_modules=['simplesam'],
25
+ scripts=['scripts/pileup.py'],
32
26
  install_requires=['six', 'ordereddict']
33
- )
27
+ )
@@ -1,22 +1,28 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: simplesam
3
- Version: 0.1.4.0
3
+ Version: 0.1.4.2
4
4
  Summary: Simple pure Python SAM parser and objects for working with SAM records
5
5
  Home-page: http://mattshirley.com
6
6
  Author: Matthew Shirley
7
7
  Author-email: mdshw5@gmail.com
8
8
  License: MIT
9
- Platform: UNKNOWN
10
- Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Development Status :: 5 - Production/Stable
11
10
  Classifier: License :: OSI Approved :: MIT License
12
11
  Classifier: Environment :: Console
13
12
  Classifier: Intended Audience :: Science/Research
14
13
  Classifier: Natural Language :: English
15
14
  Classifier: Operating System :: Unix
16
15
  Classifier: Programming Language :: Python :: 2.7
17
- Classifier: Programming Language :: Python :: 3.4
16
+ Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
19
18
  License-File: LICENSE
20
-
21
- UNKNOWN
22
-
19
+ Requires-Dist: six
20
+ Requires-Dist: ordereddict
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: home-page
25
+ Dynamic: license
26
+ Dynamic: license-file
27
+ Dynamic: requires-dist
28
+ Dynamic: summary
@@ -0,0 +1,21 @@
1
+ .gitignore
2
+ CODE_OF_CONDUCT.md
3
+ LICENSE
4
+ README.md
5
+ __init__.py
6
+ setup.cfg
7
+ setup.py
8
+ simplesam.py
9
+ .github/workflows/deploy.yml
10
+ .github/workflows/tests.yml
11
+ docs/Makefile
12
+ docs/conf.py
13
+ docs/index.rst
14
+ docs/requirements.txt
15
+ scripts/pileup.py
16
+ simplesam.egg-info/PKG-INFO
17
+ simplesam.egg-info/SOURCES.txt
18
+ simplesam.egg-info/dependency_links.txt
19
+ simplesam.egg-info/requires.txt
20
+ simplesam.egg-info/top_level.txt
21
+ tests/__init__.py
@@ -0,0 +1 @@
1
+ simplesam
@@ -20,13 +20,22 @@ from subprocess import Popen, PIPE
20
20
  from io import TextIOWrapper
21
21
  import re
22
22
  from six import PY3, string_types
23
+ try:
24
+ from importlib.metadata import version
25
+ except ImportError:
26
+ from pkg_resources import get_distribution
27
+ version = lambda name: get_distribution(name).version
23
28
 
24
29
  try:
25
30
  from multiprocessing.dummy.connection import Connection
26
31
  except ImportError: #python2
27
32
  from _multiprocessing import Connection
28
33
 
29
- __version__ = '0.1.4.0'
34
+ __version__ = "unknown"
35
+ try:
36
+ __version__ = version("simplesam")
37
+ except Exception:
38
+ pass
30
39
 
31
40
  class DefaultOrderedDict(OrderedDict):
32
41
  def __init__(self, default, items=[]):
@@ -205,7 +214,7 @@ class Reader(object):
205
214
  seqlength = v[0].split(':')[1]
206
215
  for region in tile_region(rname, 1, int(seqlength), width):
207
216
  yield region
208
-
217
+
209
218
  def close(self):
210
219
  self.__exit__()
211
220
 
@@ -226,8 +235,8 @@ class Writer(object):
226
235
  try:
227
236
  _, ext = os.path.splitext(f.name)
228
237
  if ext == '.bam':
229
- # Why not just pipe to samtools?
230
- raise NotImplementedError("Bam writing support is not implemented.\n")
238
+ # Why not just pipe to samtools?
239
+ raise NotImplementedError("Bam writing support is not implemented.\n")
231
240
  except AttributeError: # pipe?
232
241
  pass
233
242
  self.file = f
@@ -260,7 +269,7 @@ class Writer(object):
260
269
  def write(self, sam):
261
270
  """ Write the string representation of the ``sam`` :class:`.Sam` object. """
262
271
  self.file.write(str(sam))
263
-
272
+
264
273
  def close(self):
265
274
  self.__exit__()
266
275
 
@@ -327,8 +336,8 @@ class Sam(GenomicOrder):
327
336
 
328
337
  def __len__(self):
329
338
  """ Returns the length of the portion of ``self.seq`` aligned to the reference. Unaligned reads will
330
- have len() == 0. Insertions (I) and soft-clipped portions (S) will not contribute to the aligned length.
331
-
339
+ have len() == 0. Insertions (I) and soft-clipped portions (S) will not contribute to the aligned length.
340
+
332
341
  >>> x = Sam(cigar='8M2I4M1D3M4S')
333
342
  >>> len(x)
334
343
  16
@@ -384,7 +393,7 @@ class Sam(GenomicOrder):
384
393
  yield op
385
394
  else:
386
395
  raise ValueError("CIGAR operation %s in record %s is invalid." % (op[1], self.qname))
387
-
396
+
388
397
  def gapped(self, attr, gap_char='-'):
389
398
  """ Return a :class:`.Sam` sequence attribute or tag with all
390
399
  deletions in the reference sequence represented as 'gap_char' and all
@@ -405,7 +414,7 @@ class Sam(GenomicOrder):
405
414
  except AttributeError:
406
415
  ungapped = self[attr] # get dictionary key (tag) if attribute is missing
407
416
  if len(ungapped) != len(self.seq):
408
- raise ValueError("The length of the '%s' attribute is not equal to the length of Sam.seq!" % attr)
417
+ raise ValueError("The length of the '%s' attribute is not equal to the length of Sam.seq!" % attr)
409
418
  gapped = []
410
419
  i = 0
411
420
  for n, t in self.cigars:
@@ -418,7 +427,7 @@ class Sam(GenomicOrder):
418
427
  i += n
419
428
  elif t in self._cigar_no_align:
420
429
  pass
421
- return ''.join(gapped)
430
+ return ''.join(gapped)
422
431
 
423
432
  def parse_md(self):
424
433
  """ Return the ungapped reference sequence from the MD tag, if present.
@@ -458,11 +467,11 @@ class Sam(GenomicOrder):
458
467
  except KeyError:
459
468
  self._cache['cigars'] = tuple(self.cigar_split())
460
469
  return self._cache['cigars']
461
-
470
+
462
471
  @property
463
472
  def tags(self):
464
473
  """ Parses the tags string to a dictionary if necessary.
465
-
474
+
466
475
  >>> x = Sam(tags=['XU:Z:cgttttaa', 'XB:Z:cttacgttaagagttaac', 'MD:Z:75', 'NM:i:0', 'NH:i:1', 'RG:Z:1'])
467
476
  >>> sorted(x.tags.items(), key=lambda x: x[0])
468
477
  [('MD', '75'), ('NH', 1), ('NM', 0), ('RG', '1'), ('XB', 'cttacgttaagagttaac'), ('XU', 'cgttttaa')]
File without changes
@@ -1,10 +0,0 @@
1
- LICENSE
2
- README.md
3
- setup.cfg
4
- setup.py
5
- simplesam.py
6
- simplesam.egg-info/PKG-INFO
7
- simplesam.egg-info/SOURCES.txt
8
- simplesam.egg-info/dependency_links.txt
9
- simplesam.egg-info/requires.txt
10
- simplesam.egg-info/top_level.txt