Commit 4367bf09 by Eric Coissac

--no commit message

parent 59a3c09b
#!/usr/local/bin/python
import fileinput
import re
import getopt
import sys
from obitools.fasta import fastaIterator,writeFasta
def printHelp():
print "-----------------------------------"
print " fastaComplement.py"
print "-----------------------------------"
print "fastaComplement.py <fastafile>"
print " complement and reverse all sequence in the fasta file"
print "-----------------------------------"
print "-h --help : print this help"
print "-----------------------------------"
if __name__=='__main__':
fasta = fastaIterator(fileinput.input())
for seq in fasta:
print writeFasta(seq.complement())
\ No newline at end of file
......@@ -14,9 +14,6 @@ fastaLength.py [-h|--help] <fastafile>"
"""
import fileinput
import re
import getopt
import sys
from obitools.fasta import fastaIterator,writeFasta
from obitools.utils import checkHelpOption
......
......@@ -19,15 +19,18 @@ class BioSequence(object):
'''
BioSequence constructor.
@param id: sequence identifier
@type id: str
@param seq: the sequence
@type seq: str
@param definition: sequence defintion (optional)
@type definition: str
extra named parametters can be add to associtiate complementary
@param id sequence identifier
@type id str
@param seq the sequence
@type seq str
@param definition sequence defintion (optional)
@type definition str
@param info extra named parametters can be add to associtiate complementary
data to the sequence
'''
self.seq = seq
......
"""
implement fastn sililarity search algorithm for nucleic sequences.
implement fastn/fastp sililarity search algorithm for BioSequence.
"""
class Fast(object):
......@@ -29,9 +29,10 @@ class Fast(object):
@param seq: the sequence to align
@type seq: BioSequence
@return: a int tuple (smax,pmax) where smax is the
@return: where smax is the
score of the largest diagonal and pmax the
associated shift
@rtype: a int tuple (smax,pmax)
'''
histo={}
seq = str(seq)
......
class NodeLayout(dict):
'''
Layout data associated to a tree node.
'''
pass
class TreeLayout(dict):
'''
Description of a phylogenetic tree layout
@see:
'''
def addNode(self,node):
self[node]=NodeLayout()
......@@ -15,6 +24,13 @@ class TreeLayout(dict):
return self[node].get(key,default)
def setNodesColor(self,color,predicat=True):
'''
@param color:
@type color:
@param predicat:
@type predicat:
'''
for node in self:
if callable(predicat):
change = predicat(node)
......
......@@ -3,7 +3,23 @@ import math
from obitools.svg import Scene,Circle,Line,Rectangle,Text
from obitools.tree import Tree
def displayTreeLayout(layout,width=400,height=400,radius=3):
def displayTreeLayout(layout,width=400,height=400,radius=3,scale=1.0):
'''
Convert a tree layout object in an svg file.
@param layout: the tree layout object
@type layout: obitools.tree.layout.TreeLayout
@param width: svg document width
@type width: int
@param height: svg document height
@type height: int
@param radius: default radius of node in svg unit (default 3)
@type radius: int
@param scale: scale factor applied to the svg coordinates (default 1.0)
@type scale: float
@return: str containing svg code
'''
xmin = min(layout.getAttribute(n,'x') for n in layout)
xmax = max(layout.getAttribute(n,'x') for n in layout)
ymin = min(layout.getAttribute(n,'y') for n in layout)
......@@ -12,8 +28,8 @@ def displayTreeLayout(layout,width=400,height=400,radius=3):
dx = xmax - xmin
dy = ymax - ymin
xscale = width * 0.95 / dx
yscale = height * 0.95 / dy
xscale = width * 0.95 / dx * scale
yscale = height * 0.95 / dy * scale
def X(x):
return (x - xmin ) * xscale + width * 0.025
......
......@@ -53,7 +53,7 @@ def endLessIterator(endedlist):
class ColumnFile(object):
def __init__(self,stream,sep=None,strip=True,types=None):
def __init__(self,stream,sep=None,strip=True,types=None,skip=None):
if isinstance(stream,str):
self._stream = open(stream)
elif hasattr(stream,'next'):
......@@ -70,6 +70,8 @@ class ColumnFile(object):
else:
self._types=None
self._skip = skip
def str2bool(x):
return bool(eval(x.strip()[0].upper(),{'T':True,'V':True,'F':False}))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment