def get_first_seqid(self): err = Error() str = gtlib.gt_feature_index_get_first_seqid(self.fi, err._as_parameter_) if str == None: if err.is_set(): gterror(err) return str
def get_height(self): err = Error() height = c_ulong() gtlib.gt_layout_get_height(self.layout, byref(height), err) if err.is_set(): gterror(err) return height.value
def __init__(self, diagram, width, style): err = Error() self.layout = gtlib.gt_layout_new(diagram._as_parameter_, width, style._as_parameter_, err._as_parameter_) if err.is_set(): gterror(err) self._as_parameter_ = self.layout
def get_first_seqid(self): err = Error() str = gtlib.gt_feature_index_get_first_seqid(self.fi, err) if str == None: if err.is_set(): gterror(err) return str
def get_first_seqid(self): err = Error() str = gtlib.gt_feature_index_get_first_seqid(self.fi, err._as_parameter_) if str == None: if err.is_set(): gterror(err) return str.decode('UTF-8')
def from_index(feature_index, seqid, rng, style): from ctypes import byref err = Error() if rng.start > rng.end: gterror("range.start > range.end") diagram = gtlib.gt_diagram_new(feature_index, seqid, byref(rng), style, err) if err.is_set(): gterror(err) return Diagram(diagram)
def meta_node_w(mn_p, err_p): mn = EOFNode.create_from_ptr(mn_p) err = Error(err_p) try: try: self.visit_meta_node(mn) except AttributeError: pass return 0 except GTError, errmsg: err.set(str(errmsg)) return -1
def next_w(nodepp, err): error = Error(err) try: nextnode = self.next() if nextnode: nodepp[0] = nextnode.gn else: nodepp[0] = None return 0 except GTError as errmsg: error.set(str(errmsg)) return -1
def feature_node_w(fn_p, err_p): fn = FeatureNode.create_from_ptr(fn_p) err = Error(err_p) try: try: self.visit_feature_node(fn) except AttributeError: pass return 0 except GTError, errmsg: err.set(str(errmsg)) return -1
def comment_node_w(cn_p, err_p): cn = CommentNode.create_from_ptr(cn_p) err = Error(err_p) try: try: self.visit_comment_node(cn) except AttributeError: pass return 0 except GTError, errmsg: err.set(str(errmsg)) return -1
def next_w(nodepp, err): error = Error(err) try: nextnode = self.next() if nextnode: nodepp[0] = nextnode.gn else: nodepp[0] = None return 0 except Error, errmsg: error.set(str(errmsg)) return -1
def sequence_node_w(sn_p, err_p): sn = SequenceNode.create_from_ptr(sn_p) err = Error(err_p) try: try: self.visit_sequence_node(sn) except AttributeError: pass return 0 except GTError, errmsg: err.set(str(errmsg)) return -1
def eof_node_w(en_p, err_p): en = EOFNode.create_from_ptr(en_p) err = Error(err_p) try: try: self.visit_eof_node(en) except AttributeError: pass return 0 except GTError, errmsg: err.set(str(errmsg)) return -1
def region_node_w(rn_p, err_p): rn = RegionNode.create_from_ptr(rn_p) err = Error(err_p) try: try: self.visit_region_node(rn) except AttributeError: pass return 0 except GTError, errmsg: err.set(str(errmsg)) return -1
def from_index(feature_index, seqid, rng, style): from ctypes import byref FeatureIndex.from_param(feature_index) Style.from_param(style) err = Error() if rng.start > rng.end: gterror("range.start > range.end") diagram = gtlib.gt_diagram_new(feature_index._as_parameter_, seqid, byref(rng), style._as_parameter_, err._as_parameter_) if err.is_set(): gterror(err) return Diagram(diagram)
def next_w(nodepp, err): error = Error(err) try: nextnode = self.next() if nextnode: nodepp[0] = nextnode.gn else: nodepp[0] = None return 0 except Error: import sys errmsg = sys.exc_info()[1] error.set(str(errmsg)) return -1
def eof_node_w(en_p, err_p): en = EOFNode.create_from_ptr(en_p) err = Error(err_p) try: try: self.visit_eof_node(en) except AttributeError: pass return 0 except GTError: import sys errmsg = sys.exc_info()[1] err.set(str(errmsg)) return -1
def __init__(self, filename): err = Error() rdb = gtlib.gt_rdb_sqlite_new(filename, err._as_parameter_) if rdb == None: gterror(err) self.rdb = rdb self._as_parameter_ = self.rdb
def add_gff3file(self, filename): err = Error() rval = gtlib.gt_feature_index_add_gff3file(self.fi, filename.encode('UTF-8'), err) if rval != 0: gterror(err)
def __init__(self): err = Error() ads = gtlib.gt_anno_db_gfflike_new() if ads == None: gterror(err) self.ads = ads self._as_parameter_ = self.ads
def mirror(self): if self.is_mirrored(): gterror("encoded sequence is already mirrored") err = Error() ret = gtlib.gt_encseq_mirror(self.encseq, err.error) if ret != 0: gterror(err)
def encode(self, seqfiles, indexname): if not isinstance(seqfiles, list): raise TypeError("argument must be a list of strings") if len(seqfiles) == 0: raise Error("list of input sequence files must be non-empty") sa = StrArray() for f in seqfiles: if not os.path.exists(str(f)): raise IOError("file not found: %s" % str(f)) sa.add(str(f)) err = Error() esptr = gtlib.gt_encseq_encoder_encode(self.ee, sa.strarr, str(indexname).encode("UTF-8"), err.error) if esptr != 0: gterror(err)
def to_str(self): err = Error() string = Str() if gtlib.gt_style_to_str(self.style, string, err) == 0: return str(string) else: gterror(err)
def load_str(self, string): err = Error() strg = Str(str(string.encode("utf-8"))) rval = gtlib.gt_style_load_str(self.style, strg._as_parameter_, err._as_parameter_) if rval != 0: gterror(err)
def to_file(self, filename): err = Error() rval = gtlib.gt_canvas_cairo_file_to_file( self.canvas, str(filename).encode('UTF-8'), err) if rval != 0: gterror(err)
def get_feature_index(self, rdb): err = Error() fi = gtlib.gt_anno_db_schema_get_feature_index(self.ads, rdb._as_parameter_, err._as_parameter_) if fi == None: gterror(err) return FeatureIndexFromPtr(fi)
def to_str(self): err = Error() string = Str() if gtlib.gt_style_to_str(self.style, string._as_parameter_, err._as_parameter_) == 0: return str(string) else: gterror(err)
def __init__(self, style, width, height, ii=None): err = Error() canvas = gtlib.gt_canvas_cairo_file_new(style, GRAPHICS_PNG, width, height, ii, err) if canvas == None: gterror(err) self.canvas = canvas self._as_parameter_ = self.canvas
def has_seqid(self, seqid): from ctypes import c_int, byref val = c_int() err = Error() ret = gtlib.gt_feature_index_has_seqid(self.fi, byref(val), seqid, err) if ret != 0: gterror(err) else: return (val.value > 0)
def get_seqids(self): result = [] err = Error() stra = StrArray(gtlib.gt_feature_index_get_seqids(self.fi, err)) if stra == None: gterror(err) for i in range(stra.size()): result.append(stra.get(i)) return result
def next_tree(self): err = Error() genome_node = c_void_p() rval = gtlib.gt_node_stream_next(self.gs, byref(genome_node), err) if rval != 0: gterror(err) if genome_node.value == None: return None else: return GenomeNode.create_from_ptr(genome_node.value)
def create_from_file(indexname): if not os.path.exists(indexname + ".al1"): raise IOError, ("file not found: %s" % (indexname + ".al1")) e = Error() a_ptr = gtlib.gt_alphabet_new_from_file(str(indexname), e) a = Alphabet(a_ptr, True) if a == None: gterror(e) else: return a
def sketch(self, canvas): err = Error() had_err = gtlib.gt_layout_sketch(self.layout, canvas._as_parameter_, err._as_parameter_) if err.is_set(): gterror(err)
def sketch(self, canvas): err = Error() had_err = gtlib.gt_layout_sketch(self.layout, canvas, err) if err.is_set(): gterror(err)