Exemplo n.º 1
0
 def auto_file(self):
     pairs = []
     p = pd.read_csv(self.pairs_file, sep='\n', header=None, nrows=30)
     p = '\n'.join(p[0])
     if 'path length' in p or 'MAXIMUM GAP' in p:
         collinearity = base.read_colinearscan(self.pairs_file)
         pairs = [[v[0], v[2]] for k in collinearity for v in k[1]]
     elif 'MATCH_SIZE' in p or '## Alignment' in p:
         collinearity = base.read_mcscanx(self.pairs_file)
         pairs = [[v[0], v[2]] for k in collinearity for v in k[1]]
     elif '# Alignment' in p:
         collinearity = base.read_coliearity(self.pairs_file)
         pairs = [[v[0], v[2]] for k in collinearity for v in k[1]]
     elif '###' in p:
         collinearity = base.read_jcvi(self.pairs_file)
         pairs = [[v[0], v[2]] for k in collinearity for v in k[1]]
     elif ',' in p:
         collinearity = pd.read_csv(self.pairs_file, header=None)
         pairs = collinearity.values.tolist()
     else:
         collinearity = pd.read_csv(self.pairs_file, header=None, sep='\t')
         pairs = collinearity.values.tolist()
     df = pd.DataFrame(pairs)
     df = df.drop_duplicates()
     df[0] = df[0].astype(str)
     df[1] = df[1].astype(str)
     df.index = df[0]+','+df[1]
     return df
Exemplo n.º 2
0
 def auto_file(self, gff1, gff2):
     f=open(self.collinearity)
     p=' '.join(f.readlines()[0:30])
     if 'path length' in p or 'MAXIMUM GAP' in p:
         collinearity = base.read_colinearscan(self.collinearity)
     elif 'MATCH_SIZE' in p or '## Alignment' in p:
         col = base.read_mcscanx(self.collinearity)
         collinearity = []
         for block in col:
             newblock = []
             for k in block[1]:
                 if k[0] not in gff1.index or k[2] not in gff2.index:
                     continue
                 k[1], k[3] = gff1.loc[k[0], 'order'], gff2.loc[k[2], 'order']
                 newblock.append(k)
             if len(newblock) == 0:
                 continue
             collinearity.append([block[0], newblock, block[2]])
     elif '# Alignment' in p:
         collinearity = base.read_collinearity(self.collinearity)
     elif '###' in p:
         col = base.read_jcvi(self.collinearity)
         collinearity = []
         for block in col:
             newblock = []
             for k in block[1]:
                 if k[0] not in gff1.index or k[2] not in gff2.index:
                     continue
                 k[1], k[3] = gff1.loc[k[0], 'order'], gff2.loc[k[2], 'order']
                 newblock.append(k)
             if len(newblock) == 0:
                 continue
             collinearity.append([block[0], newblock, block[2]])
     return collinearity
Exemplo n.º 3
0
 def run(self):
     lens1 = base.newlens(self.lens1, self.position)
     lens2 = base.newlens(self.lens2, self.position)
     gff1 = base.newgff(self.gff1)
     gff2 = base.newgff(self.gff2)
     gff1 = gff1[gff1['chr'].isin(lens1.index)]
     gff2 = gff2[gff2['chr'].isin(lens2.index)]
     blast = base.newblast(self.blast, int(self.score), float(self.evalue),
                           gff1, gff2)
     blast = self.blast_homo(blast, gff1, gff2, int(self.repnum))
     blast.index = blast[0] + ',' + blast[1]
     colinearity = base.read_colinearscan(self.colinearity)
     ks = base.read_ks(self.ks, self.ks_col)
     data = self.block_position(colinearity, blast, gff1, gff2, ks)
Exemplo n.º 4
0
 def rewriteblock(self, blast, file, fout):
     num = 0
     fout = open(fout, 'w')
     collinearity = base.read_colinearscan(file)
     for block in collinearity:
         num += 1
         if block[1][-1][0] + ',' + block[1][-1][2] not in blast.index:
             block[1] = block[1][:-1]
         fout.write('the ' + str(num) + 'th path length ' +
                    str(len(block[1])) + '\n')
         for k in block[1]:
             s = ' '.join([str(i) for i in k])
             fout.write(s + '\n')
         fout.write('>LOCALE p-value :' + block[2] + '\n\n')
Exemplo n.º 5
0
 def auto_file(self, gff1, gff2):
     p = pd.read_csv(self.collinearity, sep='\n', header=None, nrows=30)
     p = '\n'.join(p[0])
     if 'path length' in p or 'MAXIMUM GAP' in p:
         collinearity = base.read_colinearscan(self.collinearity)
     elif 'MATCH_SIZE' in p or '## Alignment' in p:
         col = base.read_mcscanx(self.collinearity)
         collinearity = []
         for block in col:
             newblock = []
             for k in block[1]:
                 if k[0] not in gff1.index or k[2] not in gff2.index:
                     continue
                 k[1], k[3] = gff1.loc[k[0], 'order'], gff2.loc[k[2],
                                                                'order']
                 newblock.append(k)
             if len(newblock) == 0:
                 continue
             collinearity.append([block[0], newblock, block[2]])
     elif '# Alignment' in p:
         collinearity = base.read_coliearity(self.collinearity)
     return collinearity