def GetCounts(FileName): global Bases, Counts Bases = {} Counts = {} Bases["Constrained"] = 0 Counts["Constrained"] = 0 gff.GetRecs(FileName, DoRec) return Counts, Bases
print >> sys.stderr, sys.argv[0], "***ERROR***", s sys.exit(1) def DoRec(): global GeneIndexes AttrDict = gff.GetAttrDict() CurrGeneIndex = gff.GetIntAttr("gene_index", -1) if CurrGeneIndex == -1: gff.WriteRec(sys.stdout) return Key = gff.Label + "." + str(CurrGeneIndex) if Key in GeneIndexes.keys(): NewGeneIndex = GeneIndexes[Key] else: NewGeneIndex = len(GeneIndexes) GeneIndexes[Key] = NewGeneIndex AttrDict["gene_index"] = NewGeneIndex gff.SetAttrsFromDict(AttrDict) gff.WriteRec(sys.stdout) FileName = sys.argv[1] GeneIndexes = {} gff.GetRecs(FileName, DoRec) print >> sys.stderr, len(GeneIndexes), "genes found"