import sys import traceback from mpileLineTemp import mpileLineTemp from mpSample import mpSample if __name__ == "__main__": mpile_in = sys.argv[1] with open(mpile_in) as pileFile: for line in pileFile: try: pile_line = mpileLineTemp(line) except Exception, e: print sys.exc_info()[0] print traceback.format_exc() print line pileFile.close()
""" # any(lower <= postcode <= upper for (lower, upper) in [(1000, 2249), (2555, 2574), ...]) if any( float(low) <= float(pos) <= float(high) for (low, high) in TE_ranges[chrom]): return False return True if __name__ == "__main__": TE_file_loc, mp_file_loc = sys.argv[1], sys.argv[2] loadTEranges(TE_file_loc) trimmed_mp = open( mp_file_loc[:mp_file_loc.find(".")] + "_TEremoved.mpileup", "w") removed_sites = open( mp_file_loc[:mp_file_loc.find(".")] + "_TE_sites.mpileup", "w") with open(mp_file_loc) as mp_file: for line in mp_file: mp_line = mpileLineTemp(line) if validRange(mp_line.chrom, mp_line.pos): trimmed_mp.write(line) else: trimmed_mp.write(line) removed_sites.close() mp_file.close() trimmed_mp.close()
return freqAltOther < freq def minAltBases(mutant,minCount): """ Return if the given sample has >= minCount alt reads """ return (mutant.majorAltBaseCount >= minCount) if __name__ == "__main__": mpile_in = sys.argv[1] with open(mpile_in) as mp_file: for line in mp_file: try: mpLine = mpileLineTemp(line) mutant = mpLine.getMutant() # print mutant.__repr__() if mutant != None: if minAltBases(mutant,3): # print "Pass min alt base" if mutant.altReadBothStrands(): # print "pass alt both strands" #print "Mutant: " + mutant.__repr__() #print line if maxFreqAltOtherSamples(mutant,mpLine.samples,0.02): #print "pass max freq other samples" print "pass" except: print sys.exc_info()[0]