Skip to content
Snippets Groups Projects
ClassSegFeat.py 1.6 KiB
Newer Older
class Segment:
    def __init__(self,id,feature,chr,start,stop):
        self.id=id
        self.features=feature # list of the features on this segment. if thre feature is on the + strand, it will be named '+feature_id', else '-feature_id'

        # position on the reference genome
        self.chr=chr
        self.start=int(start)
        self.stop=int(stop)
        
        self.size=self.stop-self.start+1
        
    def __str__(self):
        return f"id={self.id}, position sur nipponbare={self.chr}:{self.start}-{self.stop}, size={self.size}, features={self.features}"
class Feature:
    def __init__(self,id,type,chr,start,stop,annot,childs,parent,seg):
        self.id=id
        self.type=type
        
        # position on the reference genome
        self.chr=chr
        self.start=int(start)
        self.stop=int(stop)
        
        self.size=int(stop)-int(start)+1
        
        self.annot=annot
        self.childs=childs # liste of childs features (exons, cds, etc)
        self.parent=parent
        self.segments_list=seg # list of oriented segment on which the feature is (-s1/+s1, depending on the strand)
        
    def __str__(self):
        if self.parent=="":
            return f"id={self.id}, type={self.type}, segments={self.segments_list}, position sur la référence={self.chr}:{self.start}-{self.stop}, childs={self.childs}, annotation={self.annot}"
        else:
            return f"id={self.id}, type={self.type}, segments={self.segments_list}, position sur la référence={self.chr}:{self.start}-{self.stop}, parent={self.parent}, childs={self.childs}, annotation={self.annot}"