コード例 #1
0
ファイル: bedgraph.py プロジェクト: bow/track
 def newFeature(self, chrom, feature):
     # Put the fields in the right order #
     line = [feature[i] for i in self.indices]
     # Convert the score #
     line[2] = format_float(line[2])
     # Make sure eveything is a string #
     line = [str(f) for f in line]
     # Write one line #
     self.file.write(' '.join([chrom] + line) + '\n')
コード例 #2
0
ファイル: bedgraph.py プロジェクト: nancygiang/track
 def newFeature(self, chrom, feature):
     # Put the fields in the right order #
     line = [feature[i] for i in self.indices]
     # Convert the score #
     line[2] = format_float(line[2])
     # Make sure eveything is a string #
     line = [str(f) for f in line]
     # Write one line #
     self.file.write(' '.join([chrom] + line) + '\n')
コード例 #3
0
 def newFeature(self, chrom, feature):
     # Put the fields in the right order #
     if self.indices: line = [feature[i] if i != None else '' for i in self.indices]
     else:            line = list(feature)
     # Convert the score #
     try: line[3] = format_float(line[3])
     except IndexError: pass
     # Convert the strand #
     try: line[4] = int_to_strand(line[4])
     except IndexError: pass
     # Make sure eveything is a string #
     line = [str(f) for f in line]
     # Write one line #
     self.file.write('\t'.join([chrom] + line) + '\n')
コード例 #4
0
 def newFeature(self, chrom, feature):
     # Put the fields in the right order #
     if self.indices: f = [feature[i] for i in self.indices]
     else:            f = list(feature)
     start, end, span, score = f[0], f[1], f[1]-f[0], format_float(f[2])
     # Look ahead #
     if not self.previous_end:
         self.writeFixedStep(chrom, start, end, span, score)
         return
     # If we have the same span just add the score #
     if start == self.previous_end and span == self.previous_span:
         self.file.write(score + '\n')
         self.previous_end += span
     else:
         self.writeFixedStep(chrom, start, end, span, score)
コード例 #5
0
ファイル: gff.py プロジェクト: bow/track
 def newFeature(self, chrom, feature):
     # Put the fields in the right order #
     line = range(len(all_fields))
     for n,i in enumerate(self.indices):
         if i == -1: line[n] = defaults[n]
         else:       line[n] = feature[i]
     # Convert the score #
     line[4] = format_float(line[4])
     # Convert the strand #
     line[5] = int_to_strand(line[5])
     # Convert the frame #
     if line[6] == '' or line[6] == None: line[6] = '.'
     # Make sure eveything is a string #
     line = [str(f) for f in line]
     # Write one line #
     self.file.write('\t'.join([chrom] + line) + '\n')
コード例 #6
0
 def newFeature(self, chrom, feature):
     # Put the fields in the right order #
     line = range(len(all_fields))
     for n,i in enumerate(self.indices):
         if i == -1: line[n] = defaults[n]
         else:       line[n] = feature[i]
     # Convert the score #
     line[4] = format_float(line[4])
     # Convert the strand #
     line[5] = int_to_strand(line[5])
     # Convert the frame #
     if line[6] == '' or line[6] == None: line[6] = '.'
     # Make sure eveything is a string #
     line = [str(f) for f in line]
     # Write one line #
     self.file.write('\t'.join([chrom] + line) + '\n')