<commit_before>#!/usr/bin/python

import pandas as pd
from COBLocus import COBLocus

class COBGene(COBLocus):
    def __init__(self,GrameneID,gene_build='5b'):
        self.GrameneID = GrameneID
        # Create a dummy locus
        super(COBGene,self).__init__(0,0,0,gene_build)
        try:
            (self.ID,
            self.chromosome,
            self.chromo_start,
            self.chromo_end) = self.fetchone('''SELECT ID, chromosome, chromo_start, chromo_end
                FROM genes WHERE GrameneID = '{}' and build = '{}' '''.format(self.GrameneID,self.gene_build))
        except (TypeError,ValueError) as e: 
            self.log("{} Not found for build {}".format(GrameneID,gene_build))
            self.ID = None

    @property
    def common_name(self):
        pass

    @property
    def arab_ortho(self):
        pass

    @property
    def go_terms(self):
        pass

    def __repr__(self):
        return str(self)

    def __str__(self):
        return "COBGene: {}".format(self.GrameneID)

def import_gene_list(filename,delim="\n",gene_build='5a'):
    ''' This reads a file in line by line and creates a list of gene object
        the filter call is to get rid of genes not in the database, since the
        COBGene class returns None for genes it does not find in database '''
    return filter(lambda x:x, [COBGene(x,gene_build) for x in open(filename,'r').read().strip().split(delim)])

def gene_list(gene_build='5a',*args):
    ''' This creates a list of COBGene objects from grmzm names '''
    return filter(lambda x:x, [COBGene(x,gene_build) for x in args])
<commit_msg>fixed bug in gene_list convenience method<commit_after>#!/usr/bin/python

import pandas as pd
from COBLocus import COBLocus

class COBGene(COBLocus):
    def __init__(self,GrameneID,gene_build='5b'):
        self.GrameneID = GrameneID
        # Create a dummy locus
        super(COBGene,self).__init__(0,0,0,gene_build)
        try:
            (self.ID,
            self.chromosome,
            self.chromo_start,
            self.chromo_end) = self.fetchone('''SELECT ID, chromosome, chromo_start, chromo_end
                FROM genes WHERE GrameneID = '{}' and build = '{}' '''.format(self.GrameneID,self.gene_build))
        except (TypeError,ValueError) as e: 
            self.log("{} Not found for build {}".format(GrameneID,gene_build))
            self.ID = None

    @property
    def common_name(self):
        pass

    @property
    def arab_ortho(self):
        pass

    @property
    def go_terms(self):
        pass

    def __repr__(self):
        return str(self)

    def __str__(self):
        return "COBGene: {}".format(self.GrameneID)

def import_gene_list(filename,delim="\n",gene_build='5a'):
    ''' This reads a file in line by line and creates a list of gene object
        the filter call is to get rid of genes not in the database, since the
        COBGene class returns None for genes it does not find in database '''
    return filter(lambda x:x, [COBGene(x,gene_build) for x in open(filename,'r').read().strip().split(delim)])

def gene_list(gene_list,gene_build='5a'):
    ''' This creates a list of COBGene objects from grmzm names '''
    return filter(lambda x:x, [COBGene(x,gene_build) for x in gene_list])

{'fraction_non_alphanumeric': 0.11192885617908617, 'fraction_numerical': 0.0036798528058877645, 'mean_word_length': 2.8376470588235296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5658065', 'n_tokens_mistral': 1086, 'n_tokens_neox': 1026, 'n_words': 289}