Skip to content

Commit

Permalink
fix bug for sep '|'
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangrengang committed Dec 16, 2024
1 parent ad47355 commit f0bc9e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions soi/OrthoFinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ def species_specific_genes(OFdir, sp, outTsv, ex_sps=[]):
print('\t'.join(['gene', 'group']), file=outTsv)
d_genes = result.get_species_specific2(sp, ex_sps)
for gene, group in sorted(d_genes.items()):
print('\t'.join([gene.split('|')[1], str(group)]), file=outTsv)
print('\t'.join([gene.split('|', 1)[1], str(group)]), file=outTsv)

def bootstrap_species_tree(OFdir, outdir, bootstrap=1000, iqtree_options='-mset JTT'):
'''重新用iqtree建树'''
Expand Down Expand Up @@ -1878,7 +1878,7 @@ def gene_format_common(gene):
if not '|' in gene:
sp, g = None, gene
return (sp, g)
sp, g = gene.split('|')
sp, g = gene.split('|', 1)
sp1 = sp[:len(sp)/2]
sp2 = sp[len(sp)/2+1:]
if sp1 == sp2:
Expand Down Expand Up @@ -2123,7 +2123,7 @@ def og2gene(OFdir, oglist, outsv, species=None):
if not og in oglist:
continue
for gene in group.get_group(sps=species):
gene = gene.split('|')[-1]
gene = gene.split('|', 1)[-1]
line = [gene, og] #+ group.raw_genes
print('\t'.join(line), file=outsv)
def classify_genes(OFdir, outsv=sys.stdout, species=None):
Expand All @@ -2135,7 +2135,7 @@ def add_og(OFdir, richfile, outrichfile):
for group in OrthoFinder(OFdir).orthogroups:
og = group.ogid
for gene in group.get_group():
gene = gene.split('|')[-1]
gene = gene.split('|', 1)[-1]
d_genes[gene] = og

for i, line in enumerate(open(richfile)):
Expand Down
6 changes: 3 additions & 3 deletions soi/mcscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ def gene_pairs(self):
def gene_genes(self):
return [list(map(self.gene2geneid, genes)) for genes in self.genes]
def gene2geneid(self, gene):
return gene.split('|')[1]
return gene.split('|', 1)[1]
def parse_genes(self, genes1,genes2):
self.pairs = list(zip(genes1,genes2))
self.ks = []
Expand Down Expand Up @@ -768,7 +768,7 @@ def anchors2bed(collinearity, gff, chrmap, left_anchors, right_anchors, outbed=s
g2_range = '{}-{}'.format(left_g2.raw_gene, right_g2.raw_gene)
g1_range = '{}-{}'.format(left_g1.raw_gene, right_g1.raw_gene)
id = '{}:{}:{}'.format(sp2, g2_range, g1_range)
line = [chr2.split('|')[-1], g2_start-1, g2_end, id, sp2, ]
line = [chr2.split('|', 1)[-1], g2_start-1, g2_end, id, sp2, ]
line = list(map(str, line))
print('\t'.join(line), file=outbed)
left_gs.add(left_g1)
Expand All @@ -778,7 +778,7 @@ def anchors2bed(collinearity, gff, chrmap, left_anchors, right_anchors, outbed=s
left_g1, left_g2 = min(left_gs, key=lambda x:x.start), max(right_gs, key=lambda x:x.end)
g1_chr, g1_start, g1_end = left_g1.chr, left_g1.start, right_g1.end
id = '{}:{}'.format(anchor_sp, g1_range)
line = [anchor_chr.split('|')[-1], g1_start-1, g1_end, id, anchor_sp, ]
line = [anchor_chr.split('|', 1)[-1], g1_start-1, g1_end, id, anchor_sp, ]
line = list(map(str, line))
print('\t'.join(line), file=outbed)

Expand Down

0 comments on commit f0bc9e3

Please sign in to comment.