コード例 #1
0
def genenum_to_geneabbr(num, virus):
    '''
        Attempt to lookup gene abbreviation from its position
        
        >>> for i in range( 1, 9 ):
        ...   genenum_to_geneabbr( i, 'H3N2' )
        'PB2'
        'PB1'
        'PA'
        'HA'
        'NP'
        'NA'
        'MP'
        'NS'
    '''
    num = int(num)

    genes = GENES.get(virus, False)
    if genes:
        if len(genes) > num and num >= 0:
            return genes[num]
        else:
            raise ValueError("%s is out of bounds" % num)
    else:
        raise ValueError("%s has no associated genes" % virus)
コード例 #2
0
ファイル: util.py プロジェクト: VDBWRAIR/pyWrairLib
def genenum_to_geneabbr( num, virus ):
    '''
        Attempt to lookup gene abbreviation from its position
        
        >>> for i in range( 1, 9 ):
        ...   genenum_to_geneabbr( i, 'H3N2' )
        'PB2'
        'PB1'
        'PA'
        'HA'
        'NP'
        'NA'
        'MP'
        'NS'
    '''
    num = int( num )

    genes = GENES.get( virus, False )
    if genes:
        if len( genes ) > num and num >= 0:
            return genes[num]
        else:
            raise ValueError( "%s is out of bounds" % num )
    else:
        raise ValueError( "%s has no associated genes" % virus )
コード例 #3
0
def geneabbr_to_genenum(abbr, virus):
    '''
        Attempt to lookup gene position number from gene abbreviation
        
        >>> g = ['PB2', 'PB1', 'PA', 'HA', 'NP', 'NA', 'MP', 'NS']
        >>> for gene in g:
        ...   geneabbr_to_genenum( gene, 'H3N2' )
        1
        2
        3
        4
        5
        6
        7
        8
    '''
    genes = GENES.get(virus, False)
    # Raise ValueError if virus not found or abbr not found
    if genes:
        return genes.index(abbr)
    raise ValueError("%s has no associated genes" % virus)
コード例 #4
0
ファイル: util.py プロジェクト: VDBWRAIR/pyWrairLib
def geneabbr_to_genenum( abbr, virus ):
    '''
        Attempt to lookup gene position number from gene abbreviation
        
        >>> g = ['PB2', 'PB1', 'PA', 'HA', 'NP', 'NA', 'MP', 'NS']
        >>> for gene in g:
        ...   geneabbr_to_genenum( gene, 'H3N2' )
        1
        2
        3
        4
        5
        6
        7
        8
    '''
    genes = GENES.get( virus, False )
    # Raise ValueError if virus not found or abbr not found
    if genes:
        return genes.index( abbr )
    raise ValueError( "%s has no associated genes" % virus )