Skip to content

Commit

Permalink
use first line of filter docstring in FILTER meta, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
James Casbon committed Jun 26, 2012
1 parent 8eece3f commit ffd6062
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
13 changes: 11 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A VCFv4.0 parser for Python.
A VCFv4.0 and 4.1 parser for Python.

Online version of PyVCF documentation is available at http://pyvcf.rtfd.org/

Expand Down Expand Up @@ -112,7 +112,6 @@ There are also a number of methods::
>>> print call.called, call.gt_type, call.gt_bases, call.phased
True 0 T|T True


Metadata regarding the VCF file itself can be investigated through the
following attributes:

Expand All @@ -133,6 +132,16 @@ For example::
>>> vcf_reader.infos['AA'].desc
'Ancestral Allele'

ALT records are actually classes, so that you can interrogate them::

>>> reader = vcf.Reader(file('vcf/test/example-4.1-bnd.vcf'))
>>> _ = reader.next(); row = reader.next()
>>> print row
Record(CHROM=1, POS=2, REF=T, ALT=[T[2:3[])
>>> bnd = row.ALT[0]
>>> print bnd.withinMainAssembly, bnd.orientation, bnd.remoteOrientation, bnd.connectingSequence
True False True T

Random access is supported for files with tabix indexes. Simply call fetch for the
region you are interested in::

Expand Down
5 changes: 4 additions & 1 deletion docs/FILTERS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ I can create a class like this::


This class subclasses ``vcf.filters.Base`` which provides the interface for VCF filters.
The docstring and ``name`` are metadata about the parser.
The docstring and ``name`` are metadata about the parser. The docstring provides
the help for the script, and the first line is included in the FILTER metadata when
applied to a file.

The ``customize_parser`` method allows you to add arguments to the script.
We use the ``__init__`` method to grab the argument of interest from the parser.
Finally, the ``__call__`` method processes each record and returns a value if the
Expand Down
4 changes: 3 additions & 1 deletion scripts/vcf_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ def addfilt(filt):
f = filters[name](filter_args)
chain.append(f)
# add a filter record to the output
inp.filters[f.filter_name()] = _Filter(f.filter_name(), f.description)
short_doc = f.__doc__ or ''
short_doc = short_doc.split('\n')[0].lstrip()
inp.filters[f.filter_name()] = _Filter(f.filter_name(), short_doc)

# output must be created after all the filter records have been added
output = vcf.Writer(args.output, inp)
Expand Down
11 changes: 7 additions & 4 deletions vcf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def __call__(self, record):


class VariantGenotypeQuality(Base):
""" Filters sites with low quality variants. i.e. it is possible
to have a high site quality with many low quality calls. This
""" Filters sites with only low quality variants.
It is possible to have a high site quality with many low quality calls. This
filter demands at least one call be above a threshold quality.
"""

Expand All @@ -74,7 +75,9 @@ def __call__(self, record):


class ErrorBiasFilter(Base):
""" Some sequencing technologies, notably pyrosequencing, produce mutation
""" Filter sites that look like correlated sequencing errors.
Some sequencing technologies, notably pyrosequencing, produce mutation
hotspots where there is a constant level of noise, producing some reference
and some heterozygote calls.
Expand All @@ -98,7 +101,7 @@ def customize_parser(self, parser):
help='Filter sites above this error log odds ratio')

def __init__(self, args):
self.threshold = args.errlr
self.threshold = args.eblr
if robjects is None:
raise Exception('Please install rpy2')
self.ll_test = robjects.r('''
Expand Down

0 comments on commit ffd6062

Please sign in to comment.