Skip to content

Commit

Permalink
apply 0.6.0 release which seemed to get commited off of a branch
Browse files Browse the repository at this point in the history
  • Loading branch information
James Casbon committed Nov 27, 2012
1 parent 9b9194d commit e63960c
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 17 deletions.
10 changes: 10 additions & 0 deletions docs/HISTORY.rst
Expand Up @@ -17,6 +17,16 @@ New features should have test code sent with them.
Changes
=======

0.6.0 Release
-------------

* Backwards incompatible change: _Call.data is now a
namedtuple (previously it was a dict)
* Optional cython version, much improved performance.
* Improvements to writer (thanks @cmclean)
* Improvements to inheritance of classes (thanks @lennax)


0.5.0 Release
-------------

Expand Down
2 changes: 1 addition & 1 deletion vcf/__init__.py
Expand Up @@ -177,4 +177,4 @@
from vcf.filters import Base as Filter
from vcf.parser import RESERVED_INFO, RESERVED_FORMAT

VERSION = '0.5.0'
VERSION = '0.6.0'
42 changes: 27 additions & 15 deletions vcf/model.py
Expand Up @@ -2,6 +2,7 @@
import collections
import sys


class _Call(object):
""" A genotype call, a cell entry in a VCF file"""

Expand All @@ -20,7 +21,7 @@ def __init__(self, site, sample, data):
self.called = self.gt_nums is not None
except AttributeError:
self.gt_nums = None
# FIXME how do we know if a non GT call is called?
#62 a call without a genotype is not defined as called or not
self.called = None

def __repr__(self):
Expand Down Expand Up @@ -70,10 +71,14 @@ def gt_type(self):
if self.called:
alleles = self.gt_alleles
if all(X == alleles[0] for X in alleles[1:]):
if alleles[0] == "0": return 0
else: return 2
else: return 1
else: return None
if alleles[0] == "0":
return 0
else:
return 2
else:
return 1
else:
return None

@property
def phased(self):
Expand Down Expand Up @@ -145,7 +150,7 @@ def __str__(self):
return "Record(CHROM=%(CHROM)s, POS=%(POS)s, REF=%(REF)s, ALT=%(ALT)s)" % self.__dict__

def __cmp__(self, other):
return cmp( (self.CHROM, self.POS), (other.CHROM, other.POS))
return cmp((self.CHROM, self.POS), (other.CHROM, other.POS))

def add_format(self, fmt):
self.FORMAT = self.FORMAT + ':' + fmt
Expand Down Expand Up @@ -199,7 +204,6 @@ def aaf(self):
# skip if more than one alternate allele. assumes bi-allelic
if len(self.ALT) > 1:
return None
hom_ref = self.num_hom_ref
het = self.num_het
hom_alt = self.num_hom_alt
num_chroms = float(2.0 * self.num_called)
Expand Down Expand Up @@ -244,7 +248,8 @@ def get_unknowns(self):
@property
def is_snp(self):
""" Return whether or not the variant is a SNP """
if len(self.REF) > 1: return False
if len(self.REF) > 1:
return False
for alt in self.ALT:
if alt is None or alt.type != "SNV":
return False
Expand All @@ -257,7 +262,8 @@ def is_indel(self):
""" Return whether or not the variant is an INDEL """
is_sv = self.is_sv

if len(self.REF) > 1 and not is_sv: return True
if len(self.REF) > 1 and not is_sv:
return True
for alt in self.ALT:
if alt is None:
return True
Expand All @@ -284,7 +290,8 @@ def is_sv(self):
def is_transition(self):
""" Return whether or not the SNP is a transition """
# if multiple alts, it is unclear if we have a transition
if len(self.ALT) > 1: return False
if len(self.ALT) > 1:
return False

if self.is_snp:
# just one alt allele
Expand All @@ -294,14 +301,17 @@ def is_transition(self):
(self.REF == "C" and alt_allele == "T") or
(self.REF == "T" and alt_allele == "C")):
return True
else: return False
else: return False
else:
return False
else:
return False

@property
def is_deletion(self):
""" Return whether or not the INDEL is a deletion """
# if multiple alts, it is unclear if we have a transition
if len(self.ALT) > 1: return False
if len(self.ALT) > 1:
return False

if self.is_indel:
# just one alt allele
Expand All @@ -310,8 +320,10 @@ def is_deletion(self):
return True
if len(self.REF) > len(alt_allele):
return True
else: return False
else: return False
else:
return False
else:
return False

@property
def var_type(self):
Expand Down
2 changes: 1 addition & 1 deletion vcf/test/prof.py
@@ -1,4 +1,4 @@
import vcf
import vcf as vcf

This comment has been minimized.

Copy link
@martijnvermaat

martijnvermaat Nov 27, 2012

Collaborator

Out of curiosity, what does this mean?

This comment has been minimized.

Copy link
@casbon

casbon via email Nov 27, 2012

This comment has been minimized.

Copy link
@martijnvermaat

martijnvermaat Nov 27, 2012

Collaborator

Sorry, I meant this specific line, import vcf as vcf, what's the difference with import vcf?

This comment has been minimized.

Copy link
@casbon

casbon via email Nov 28, 2012

import cProfile
import timeit
import pstats
Expand Down

0 comments on commit e63960c

Please sign in to comment.