https://github.com/stephenfloor/tripseq-analysis
Raw File
Tip revision: 3e823abcca5b8c1e5e89dd9bd4c49e8673b3e957 authored by Stephen Floor on 24 June 2017, 00:52:49 UTC
email update
Tip revision: 3e823ab
AnnotationConverter.py
# converts between two annotation sets.  First column of input is assumed to be the "from" annotations, and second column is the "to" annotations

# i.e. 

# ENST00000517143 NR_046932

# will convert from ensembl to refseq 


from collections import defaultdict 

class AnnotationConverter:
    def __init__(self, annotConvFile):
        
        self.conversion = defaultdict(list)
        
        for line in annotConvFile:
            line = line.split()
            self.conversion[line[0]].append(line[1])
            
    def convert(self, id):
        #print "AnnotConv: %s maps to %s" % (id, self.conversion[id])
        return self.conversion[id]

back to top