当前位置: 首页>>代码示例>>Python>>正文


Python GFFParser.parse_simple方法代码示例

本文整理汇总了Python中BCBio.GFF.GFFParser.parse_simple方法的典型用法代码示例。如果您正苦于以下问题:Python GFFParser.parse_simple方法的具体用法?Python GFFParser.parse_simple怎么用?Python GFFParser.parse_simple使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BCBio.GFF.GFFParser的用法示例。


在下文中一共展示了GFFParser.parse_simple方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: t_simple_parsing

# 需要导入模块: from BCBio.GFF import GFFParser [as 别名]
# 或者: from BCBio.GFF.GFFParser import parse_simple [as 别名]
 def t_simple_parsing(self):
     """Parse GFF into a simple line by line dictionary without nesting.
     """
     parser = GFFParser()
     num_lines = 0
     for line_info in parser.parse_simple(self._test_gff_file):
         num_lines += 1
     assert num_lines == 177, num_lines
     line_info = line_info['child'][0]
     assert line_info['quals']['confirmed_est'] == \
             ['yk1055g06.5', 'OSTF085G5_1']
     assert line_info['location'] == [4582718, 4583189]
开发者ID:JCVI-Cloud,项目名称:VICVB,代码行数:14,代码来源:test_GFFSeqIOFeatureAdder.py

示例2: simpleGFF2PygrSQLite

# 需要导入模块: from BCBio.GFF import GFFParser [as 别名]
# 或者: from BCBio.GFF.GFFParser import parse_simple [as 别名]
class simpleGFF2PygrSQLite(object):
    def __init__(self,liteserver):
        """Uses BCBio.GFF.GFFparser.parse_simple() to initiate and populate SQLite tables.
        No 'nested' Parent:Child relationships are used, but P:C info can be accessed in parse_simple
        results.  For NOW, only essential data for pygrSliceObj is recorded.
        Returns: I THINK nothing --> external liteserver should be populated after loop?
        """
        self._parser   = GFFParser()
        self.srvrInfo  = liteserver
        self.tables    = {}  # <-- should add func to populate this on init if any already exist in serverInfo
        

    def _newRow(self, sliceObj):
        '''Creates new row in correct table.  Creates new table if need be.
        '''
        
        # Do we have to make a new table?
        if sliceObj.featureType in self.tables:
            # Get next k integer
            k = len(self.tables[sliceObj.featureType]) # works bc k starts w/ 0
            
            self.tables[sliceObj.featureType].new(k              = k,
                                                  seq_id         = sliceObj.seq_id,
                                                  start          = sliceObj.start,
                                                  stop           = sliceObj.stop,
                                                  orientation    = sliceObj.orientation,
                                                  featureType    = sliceObj.featureType,
                                                  gffKind        = sliceObj.gffKind,
                                                  coordReference = sliceObj.coordReference,
                                                  Parent         = sliceObj.Parent,
                                                  description    = sliceObj.description)
        else:
            self._newTable(sliceObj)
            
    def _newTable(self,sliceObj):
        '''Convert parsed GFF data to correct sql CREATE command, and add
        tableObj and keyName to self.tables.
        '''
        sqlCmd = 'CREATE TABLE %s (k INTEGER PRIMARY KEY, seq_id TEXT, start INT, stop INT, orientation INT, featureType TEXT, gffKind TEXT, coordReference TEXT, Parent TEXT, description TEXT,);'
        self.tables[sliceObj.featureType] = sqlgraph.SQLTable(sliceObj.featureType,
                                                              serverInfo=self.srvrInfo,
                                                              writeable=True,
                                                              createTable=sqlCmd)
        
        self.tables[sliceObj.featureType].new(k              = 0,
                                              seq_id         = sliceObj.seq_id,
                                              start          = sliceObj.start,
                                              stop           = sliceObj.stop,
                                              orientation    = sliceObj.orientation,
                                              featureType    = sliceObj.featureType,
                                              gffKind        = sliceObj.gffKind,
                                              coordReference = sliceObj.coordReference,
                                              Parent         = sliceObj.Parent,
                                              description    = sliceObj.description)
    def update(self,gffPath):
        gff      = open(gffFullPath)
        gffPrsr  = self._parser.parse_simple(gff)
        
        for rec in gffPrsr:
            # If rec == 'directive'  Move on.
            if rec.keys()[0] == 'directive':
                continue
            # else: create/add to correct table
            else:
                self.newRow(sGFFrow2SliceObj(gffRec)) # calls newTable if needed
        
        self.srvrInfo.commit()
        
    def getTableNames(self):
        srvrInfo.commit()
        cur = self.srvrInfo.cursor()
        x   = cur.execute('SELECT * FROM sqlite_master;')
        return [x[1] for x in x]    
开发者ID:xguse,项目名称:gusPyProj,代码行数:75,代码来源:gPygr.py


注:本文中的BCBio.GFF.GFFParser.parse_simple方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。