Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bio/Sequencing: PEP8 whitespace cleanup.

  • Loading branch information...
commit 85777b856df65200d4a2f6c4518860d032f4d2b5 1 parent 1bcd809
@cbrueffer cbrueffer authored peterjc committed
Showing with 126 additions and 126 deletions.
  1. +118 −118 Bio/Sequencing/Ace.py
  2. +8 −8 Bio/Sequencing/Phd.py
View
236 Bio/Sequencing/Ace.py
@@ -61,48 +61,48 @@ class rd(object):
The location and strand each read is mapped to is held in the AF lines.
"""
def __init__(self):
- self.name=''
- self.padded_bases=None
- self.info_items=None
- self.read_tags=None
- self.sequence=''
+ self.name = ''
+ self.padded_bases = None
+ self.info_items = None
+ self.read_tags = None
+ self.sequence = ''
class qa(object):
"""QA (read quality), including which part if any was used as the consensus."""
def __init__(self, line=None):
- self.qual_clipping_start=None
- self.qual_clipping_end=None
- self.align_clipping_start=None
- self.align_clipping_end=None
+ self.qual_clipping_start = None
+ self.qual_clipping_end = None
+ self.align_clipping_start = None
+ self.align_clipping_end = None
if line:
- header=map(eval,line.split()[1:])
- self.qual_clipping_start=header[0]
- self.qual_clipping_end=header[1]
- self.align_clipping_start=header[2]
- self.align_clipping_end=header[3]
+ header = map(eval, line.split()[1:])
+ self.qual_clipping_start = header[0]
+ self.qual_clipping_end = header[1]
+ self.align_clipping_start = header[2]
+ self.align_clipping_end = header[3]
class ds(object):
"""DS lines, include file name of a read's chromatogram file."""
def __init__(self, line=None):
- self.chromat_file=''
- self.phd_file=''
- self.time=''
- self.chem=''
- self.dye=''
- self.template=''
- self.direction=''
+ self.chromat_file = ''
+ self.phd_file = ''
+ self.time = ''
+ self.chem = ''
+ self.dye = ''
+ self.template = ''
+ self.direction = ''
if line:
- tags=['CHROMAT_FILE','PHD_FILE','TIME','CHEM','DYE','TEMPLATE','DIRECTION']
- poss=map(line.find,tags)
- tagpos=dict(zip(poss,tags))
+ tags = ['CHROMAT_FILE', 'PHD_FILE', 'TIME', 'CHEM', 'DYE', 'TEMPLATE', 'DIRECTION']
+ poss = map(line.find, tags)
+ tagpos = dict(zip(poss, tags))
if -1 in tagpos:
del tagpos[-1]
- ps=tagpos.keys()
+ ps = tagpos.keys()
ps.sort()
- for (p1,p2) in zip(ps,ps[1:]+[len(line)+1]):
- setattr(self,tagpos[p1].lower(),line[p1+len(tagpos[p1])+1:p2].strip())
+ for (p1, p2) in zip(ps, ps[1:]+[len(line)+1]):
+ setattr(self, tagpos[p1].lower(), line[p1+len(tagpos[p1])+1:p2].strip())
class af(object):
@@ -113,9 +113,9 @@ class af(object):
C or U character.
"""
def __init__(self, line=None):
- self.name=''
- self.coru=None
- self.padded_start=None
+ self.name = ''
+ self.coru = None
+ self.padded_start = None
if line:
header = line.split()
self.name = header[1]
@@ -126,9 +126,9 @@ def __init__(self, line=None):
class bs(object):
"""BS (base segment), which read was chosen as the consensus at each position."""
def __init__(self, line=None):
- self.name=''
- self.padded_start=None
- self.padded_end=None
+ self.name = ''
+ self.padded_start = None
+ self.padded_end = None
if line:
header = line.split()
self.padded_start = int(header[1])
@@ -139,54 +139,54 @@ def __init__(self, line=None):
class rt(object):
"""RT (transient read tags), generated by crossmatch and phrap."""
def __init__(self, line=None):
- self.name=''
- self.tag_type=''
- self.program=''
- self.padded_start=None
- self.padded_end=None
- self.date=''
- self.comment=[]
+ self.name = ''
+ self.tag_type = ''
+ self.program = ''
+ self.padded_start = None
+ self.padded_end = None
+ self.date = ''
+ self.comment = []
if line:
- header=line.split()
- self.name=header[0]
- self.tag_type=header[1]
- self.program=header[2]
- self.padded_start=int(header[3])
- self.padded_end=int(header[4])
- self.date=header[5]
+ header = line.split()
+ self.name = header[0]
+ self.tag_type = header[1]
+ self.program = header[2]
+ self.padded_start = int(header[3])
+ self.padded_end = int(header[4])
+ self.date = header[5]
class ct(object):
"""CT (consensus tags)."""
def __init__(self, line=None):
- self.name=''
- self.tag_type=''
- self.program=''
- self.padded_start=None
- self.padded_end=None
- self.date=''
- self.notrans=''
- self.info=[]
- self.comment=[]
+ self.name = ''
+ self.tag_type = ''
+ self.program = ''
+ self.padded_start = None
+ self.padded_end = None
+ self.date = ''
+ self.notrans = ''
+ self.info = []
+ self.comment = []
if line:
- header=line.split()
+ header = line.split()
self.name = header[0]
self.tag_type = header[1]
self.program = header[2]
self.padded_start = int(header[3])
self.padded_end = int(header[4])
self.date = header[5]
- if len(header)==7:
+ if len(header) == 7:
self.notrans = header[6]
class wa(object):
"""WA (whole assembly tag), holds the assembly program name, version, etc."""
def __init__(self, line=None):
- self.tag_type=''
- self.program=''
- self.date=''
- self.info=[]
+ self.tag_type = ''
+ self.program = ''
+ self.date = ''
+ self.info = []
if line:
header = line.split()
self.tag_type = header[0]
@@ -197,10 +197,10 @@ def __init__(self, line=None):
class wr(object):
"""WR lines."""
def __init__(self, line=None):
- self.name=''
- self.aligned=''
- self.program=''
- self.date=[]
+ self.name = ''
+ self.aligned = ''
+ self.program = ''
+ self.date = []
if line:
header = line.split()
self.name = header[0]
@@ -212,11 +212,11 @@ def __init__(self, line=None):
class Reads(object):
"""Holds information about a read supporting an ACE contig."""
def __init__(self, line=None):
- self.rd=None # one per read
- self.qa=None # one per read
- self.ds=None # none or one per read
- self.rt=None # none or many per read
- self.wr=None # none or many per read
+ self.rd = None # one per read
+ self.qa = None # one per read
+ self.ds = None # none or one per read
+ self.rt = None # none or many per read
+ self.wr = None # none or many per read
if line:
self.rd = rd()
header = line.split()
@@ -230,17 +230,17 @@ class Contig(object):
"""Holds information about a contig from an ACE record."""
def __init__(self, line=None):
self.name = ''
- self.nbases=None
- self.nreads=None
- self.nsegments=None
- self.uorc=None
- self.sequence=""
- self.quality=[]
- self.af=[]
- self.bs=[]
- self.reads=[]
- self.ct=None # none or many
- self.wa=None # none or many
+ self.nbases = None
+ self.nreads = None
+ self.nsegments = None
+ self.uorc = None
+ self.sequence = ""
+ self.quality = []
+ self.af = []
+ self.bs = []
+ self.reads = []
+ self.ct = None # none or many
+ self.wa = None # none or many
if line:
header = line.split()
self.name = header[1]
@@ -284,7 +284,7 @@ def parse(handle):
line = line.strip()
if not line:
break
- record.sequence+=line
+ record.sequence += line
for line in handle:
if line.strip():
@@ -295,7 +295,7 @@ def parse(handle):
for line in handle:
if not line.strip():
break
- record.quality.extend(map(int,line.split()))
+ record.quality.extend(map(int, line.split()))
for line in handle:
if line.strip():
@@ -351,7 +351,7 @@ def parse(handle):
line = line.strip()
if not line:
break
- record.reads[-1].rd.sequence+=line
+ record.reads[-1].rd.sequence += line
for line in handle:
if line.strip():
@@ -387,9 +387,9 @@ def parse(handle):
# belong to a previous read, not the actual one.
# we store it here were it appears, the user can sort later.
if record.reads[-1].rt is None:
- record.reads[-1].rt=[]
+ record.reads[-1].rt = []
for line in handle:
- line=line.strip()
+ line = line.strip()
#if line=="COMMENT{":
if line.startswith("COMMENT{"):
if line[8:].strip():
@@ -400,51 +400,51 @@ def parse(handle):
if line.endswith("C}"):
break
record.reads[-1].rt[-1].comment.append(line)
- elif line=='}':
+ elif line == '}':
break
else:
record.reads[-1].rt.append(rt(line))
line = ""
elif line.startswith("WR{"):
if record.reads[-1].wr is None:
- record.reads[-1].wr=[]
+ record.reads[-1].wr = []
for line in handle:
- line=line.strip()
- if line=='}':
+ line = line.strip()
+ if line == '}':
break
record.reads[-1].wr.append(wr(line))
line = ""
elif line.startswith("WA{"):
if record.wa is None:
- record.wa=[]
+ record.wa = []
try:
line = handle.next()
except StopIteration:
raise ValueError("Failed to read WA block")
record.wa.append(wa(line))
for line in handle:
- line=line.strip()
- if line=='}':
+ line = line.strip()
+ if line == '}':
break
record.wa[-1].info.append(line)
line = ""
elif line.startswith("CT{"):
if record.ct is None:
- record.ct=[]
+ record.ct = []
try:
line = handle.next()
except StopIteration:
raise ValueError("Failed to read CT block")
record.ct.append(ct(line))
for line in handle:
- line=line.strip()
- if line=="COMMENT{":
+ line = line.strip()
+ if line == "COMMENT{":
for line in handle:
line = line.strip()
if line.endswith("C}"):
break
record.ct[-1].comment.append(line)
- elif line=='}':
+ elif line == '}':
break
else:
record.ct[-1].info.append(line)
@@ -452,7 +452,7 @@ def parse(handle):
else:
break
- if not line.startswith('RD'): # another read?
+ if not line.startswith('RD'): # another read?
break
yield record
@@ -462,38 +462,38 @@ class ACEFileRecord(object):
"""Holds data of an ACE file.
"""
def __init__(self):
- self.ncontigs=None
- self.nreads=None
- self.contigs=[]
- self.wa=None # none or many
+ self.ncontigs = None
+ self.nreads = None
+ self.contigs = []
+ self.wa = None # none or many
def sort(self):
- """Sorts wr, rt and ct tags into the appropriate contig / read instance, if possible. """
+ """Sorts wr, rt and ct tags into the appropriate contig / read instance, if possible."""
- ct=[]
- rt=[]
- wr=[]
+ ct = []
+ rt = []
+ wr = []
# search for tags that aren't in the right position
for i in range(len(self.contigs)):
c = self.contigs[i]
if c.wa:
if not self.wa:
- self.wa=[]
+ self.wa = []
self.wa.extend(c.wa)
if c.ct:
- newcts=[ct_tag for ct_tag in c.ct if ct_tag.name!=c.name]
+ newcts = [ct_tag for ct_tag in c.ct if ct_tag.name != c.name]
for x in newcts:
self.contigs[i].ct.remove(x)
ct.extend(newcts)
for j in range(len(c.reads)):
r = c.reads[j]
if r.rt:
- newrts=[rt_tag for rt_tag in r.rt if rt_tag.name!=r.rd.name]
+ newrts = [rt_tag for rt_tag in r.rt if rt_tag.name != r.rd.name]
for x in newrts:
self.contigs[i].reads[j].rt.remove(x)
rt.extend(newrts)
if r.wr:
- newwrs=[wr_tag for wr_tag in r.wr if wr_tag.name!=r.rd.name]
+ newwrs = [wr_tag for wr_tag in r.wr if wr_tag.name != r.rd.name]
for x in newwrs:
self.contigs[i].reads[j].wr.remove(x)
wr.extend(newwrs)
@@ -501,22 +501,22 @@ def sort(self):
for i in range(len(self.contigs)):
c = self.contigs[i]
for ct_tag in ct:
- if ct_tag.name==c.name:
+ if ct_tag.name == c.name:
if self.contigs[i].ct is None:
- self.contigs[i].ct=[]
+ self.contigs[i].ct = []
self.contigs[i].ct.append(ct_tag)
if rt or wr:
for j in range(len(c.reads)):
r = c.reads[j]
for rt_tag in rt:
- if rt_tag.name==r.rd.name:
+ if rt_tag.name == r.rd.name:
if self.contigs[i].reads[j].rt is None:
- self.contigs[i].reads[j].rt=[]
+ self.contigs[i].reads[j].rt = []
self.contigs[i].reads[j].rt.append(rt_tag)
for wr_tag in wr:
- if wr_tag.name==r.rd.name:
+ if wr_tag.name == r.rd.name:
if self.contigs[i].reads[j].wr is None:
- self.contigs[i].reads[j].wr=[]
+ self.contigs[i].reads[j].wr = []
self.contigs[i].reads[j].wr.append(wr_tag)
@@ -527,7 +527,7 @@ def read(handle):
handle = iter(handle)
- record=ACEFileRecord()
+ record = ACEFileRecord()
try:
line = handle.next()
View
16 Bio/Sequencing/Phd.py
@@ -19,9 +19,9 @@
from Bio import Seq
from Bio.Alphabet import generic_dna
-CKEYWORDS=['CHROMAT_FILE','ABI_THUMBPRINT','PHRED_VERSION','CALL_METHOD',
- 'QUALITY_LEVELS','TIME','TRACE_ARRAY_MIN_INDEX','TRACE_ARRAY_MAX_INDEX',
- 'TRIM','TRACE_PEAK_AREA_RATIO','CHEM','DYE']
+CKEYWORDS = ['CHROMAT_FILE', 'ABI_THUMBPRINT', 'PHRED_VERSION', 'CALL_METHOD',
+ 'QUALITY_LEVELS', 'TIME', 'TRACE_ARRAY_MIN_INDEX', 'TRACE_ARRAY_MAX_INDEX',
+ 'TRIM', 'TRACE_PEAK_AREA_RATIO', 'CHEM', 'DYE']
class Record(object):
@@ -48,7 +48,7 @@ def read(handle):
record.file_name = line[15:].rstrip()
break
else:
- return # No record found
+ return # No record found
for line in handle:
if line.startswith("BEGIN_COMMENT"):
@@ -60,7 +60,7 @@ def read(handle):
line = line.strip()
if not line:
continue
- if line=="END_COMMENT":
+ if line == "END_COMMENT":
break
keyword, value = line.split(":", 1)
keyword = keyword.lower()
@@ -79,9 +79,9 @@ def read(handle):
'trace_array_min_index',
'trace_array_max_index'):
record.comments[keyword] = int(value)
- elif keyword=='trace_peak_area_ratio':
+ elif keyword == 'trace_peak_area_ratio':
record.comments[keyword] = float(value)
- elif keyword=='trim':
+ elif keyword == 'trim':
first, last, prob = value.split()
record.comments[keyword] = (int(first), int(last), float(prob))
else:
@@ -101,7 +101,7 @@ def read(handle):
# Peak location is optional according to
# David Gordon (the Consed author)
parts = line.split()
- if len(parts) in [2,3]:
+ if len(parts) in [2, 3]:
record.sites.append(tuple(parts))
else:
raise ValueError("DNA line must contain a base and quality "
Please sign in to comment.
Something went wrong with that request. Please try again.