Analysis.py 文件源码

python
阅读 43 收藏 0 点赞 0 评论 0

项目:BioNanoAnalyst 作者: AppliedBioinformatics 项目源码 文件源码
def convert_tables(self):
        """
        Based on the confidence score, convert xmap file and two corresponding cmap files
        into "pandas table".
        """
        pd.set_option('display.width',200)
        with open ('%s.table' % self.name, 'a') as xmap_table:
            with open (self.xmap) as xmap:
                for line in xmap:
                    if line.startswith('#h'):
                        hearder = line[3:]
                        xmap_table.write(hearder)
                    if line[0]!='#':
                        xmap_table.write(line)
        with open ('%s.rtable' % self.name, 'a') as rcmap_table:
            with open (self.rcmap) as rcmap:
                for line in rcmap:
                    if line.startswith('#h'):
                        hearder = line[3:]
                        rcmap_table.write(hearder)
                    if line[0]!='#':
                        rcmap_table.write(line)
        with open ('%s.qtable' % self.name, 'a') as qcmap_table:
            with open (self.qcmap) as qcmap:
                for line in qcmap:
                    if line.startswith('#h'):
                        hearder = line[3:]
                        qcmap_table.write(hearder)
                    if line[0]!='#':
                        qcmap_table.write(line)
        self.XmapTable = pd.read_table('%s.table' % self.name)
        headers_x = ['RefContigID','RefStartPos','RefEndPos','QryContigID','QryStartPos',
        'QryEndPos','Orientation', 'Confidence','QryLen','RefLen', 'Alignment']
        self.filtered_XmapTable = self.XmapTable[self.XmapTable['Confidence']>=self.confidence_score][headers_x].reset_index(drop=True)
        headers_r = ['CMapId','ContigLength','NumSites','SiteID','Position']
        self.RcmapTable = pd.read_table('%s.rtable' % self.name)[headers_r]
        headers_q = ['CMapId','ContigLength','NumSites','SiteID','Position','Coverage']
        self.QcmapTable = pd.read_table('%s.qtable' % self.name)[headers_q]
        os.remove('%s.table' % self.name)
        os.remove('%s.rtable' % self.name)
        os.remove('%s.qtable' % self.name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号