示例#1
0
 def __cmp__(self, other):
     if self.type != other.type:
         return self.type - other.type
     else:
         if self.type == vcfKey.REGULAR:
             if self.chromosome == other.chromosome:
                 return self.position - other.position
             else:
                 myRank = chromosomeRank.get(self.chromosome, len(chromosomeRank))
                 otherRank = chromosomeRank.get(other.chromosome, len(chromosomeRank))
                 result = myRank - otherRank
                 if result == 0:
                     # we already know they're not the same chromosome; our behavior is to sort unknown chromosomes alphabetically
                     return cmp(self.chromosome, other.chromosome)
                 else:
                     return result
         elif self.type == vcfKey.CONTIG:
             myRank = chromosomeRank.get(self.chromosome, len(chromosomeRank))
             otherRank = chromosomeRank.get(other.chromosome, len(chromosomeRank))
             result = myRank - otherRank
             if result == 0:
                 # we already know they're not the same chromosome; our behavior is to sort unknown chromosomes alphabetically
                 return cmp(self.chromosome, other.chromosome)
             else:
                 return result
         elif self.type == vcfKey.OTHER_META:
             # I could probably do a better job of this, but the .vcf spec doesn't require it so I don't care
             return cmp(self.line, other.line)
         elif self.type == vcfKey.EMPTY:
             return 0
         else:
             raise Exception("Duplicate ##fileformat or header lines!")
示例#2
0
 def __cmp__(self, other):
     if self.chromosome == other.chromosome:
         return self.start - other.start
     else:
         myRank = chromosomeRank.get(self.chromosome, len(chromosomeRank))
         otherRank = chromosomeRank.get(other.chromosome, len(chromosomeRank))
         result = myRank - otherRank
         if result == 0:
             # we already know they're not the same chromosome; our behavior is to sort unknown chromosomes alphabetically
             return cmp(self.chromosome, other.chromosome)
         else:
             return result
示例#3
0
 def __cmp__(self, other):
     if self.chromosome == other.chromosome:
         return self.start - other.start
     else:
         myRank = chromosomeRank.get(self.chromosome, len(chromosomeRank))
         otherRank = chromosomeRank.get(other.chromosome,
                                        len(chromosomeRank))
         result = myRank - otherRank
         if result == 0:
             # we already know they're not the same chromosome; our behavior is to sort unknown chromosomes alphabetically
             return cmp(self.chromosome, other.chromosome)
         else:
             return result
示例#4
0
 def __cmp__(self, other):
     if self.type != other.type:
         return self.type - other.type
     else:
         if self.type == vcfKey.REGULAR:
             if self.chromosome == other.chromosome:
                 return self.position - other.position
             else:
                 myRank = chromosomeRank.get(self.chromosome,
                                             len(chromosomeRank))
                 otherRank = chromosomeRank.get(other.chromosome,
                                                len(chromosomeRank))
                 result = myRank - otherRank
                 if result == 0:
                     # we already know they're not the same chromosome; our behavior is to sort unknown chromosomes alphabetically
                     return cmp(self.chromosome, other.chromosome)
                 else:
                     return result
         elif self.type == vcfKey.CONTIG:
             myRank = chromosomeRank.get(self.chromosome,
                                         len(chromosomeRank))
             otherRank = chromosomeRank.get(other.chromosome,
                                            len(chromosomeRank))
             result = myRank - otherRank
             if result == 0:
                 # we already know they're not the same chromosome; our behavior is to sort unknown chromosomes alphabetically
                 return cmp(self.chromosome, other.chromosome)
             else:
                 return result
         elif self.type == vcfKey.OTHER_META:
             # I could probably do a better job of this, but the .vcf spec doesn't require it so I don't care
             return cmp(self.line, other.line)
         elif self.type == vcfKey.EMPTY:
             return 0
         else:
             raise Exception("Duplicate ##fileformat or header lines!")