rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
msg['From'] = 'cedric.moullet@gmail.com'
msg['From'] = 'cedric.moullet@openaddresses.org'
def mail(self, to, subject, text): # http://kutuma.blogspot.com/2007/08/sending-emails-via-gmail-with-python.html msg = MIMEMultipart()
return os.getcwd()
return "Not implemented, for now"
def index(self, format='html'): """GET /uploads: All items in the collection""" # url('uploads') return os.getcwd()
permanent_file = open(archive.filename.lstrip(os.sep),'w')
permanent_file = open(os.path.join(self.main_root + '/trunk/openaddresses/uploads',archive.filename.lstrip(os.sep)), 'w')
def create(self): """POST /uploads: Create a new item""" archive = request.POST['uploaded_file'] email = request.POST['email'] permanent_file = open(archive.filename.lstrip(os.sep),'w') shutil.copyfileobj(archive.file, permanent_file) archive.file.close() permanent_file.close() self.mail(email,"OpenAddresses.org upload...
return dumps({"success": True})
return dumps({"success": True, "filename": permanent_file.name})
def create(self): """POST /uploads: Create a new item""" archive = request.POST['uploaded_file'] email = request.POST['email'] permanent_file = open(archive.filename.lstrip(os.sep),'w') shutil.copyfileobj(archive.file, permanent_file) archive.file.close() permanent_file.close() self.mail(email,"OpenAddresses.org upload...
sqlQuery = sqlQuery + " WHERE tsvector_street_housenumber_city @@ to_tsquery('" + tsquery + "')"
sqlQuery = sqlQuery + " WHERE tsvector_street_housenumber_city @@ to_tsquery('english', '" + tsquery + "')"
def fullTextSearch(self,request): # addresses/fullTextSearch?fields=street,city,housenumber&query=ch%20du%2028&tolerance=0.005&easting=6.62379551&northing=46.51687241&limit=20&distinct=true # Read request parameters fields = request.params['fields']
sqlQuery = sqlQuery + " WHERE tsvector_street @@ to_tsquery('" + tsquery + "')"
sqlQuery = sqlQuery + " WHERE tsvector_street @@ to_tsquery('english','" + tsquery + "')"
def fullTextSearch(self,request): # addresses/fullTextSearch?fields=street,city,housenumber&query=ch%20du%2028&tolerance=0.005&easting=6.62379551&northing=46.51687241&limit=20&distinct=true # Read request parameters fields = request.params['fields']
sqlQuery = sqlQuery + " WHERE to_tsvector(" + tsvector + ") @@ to_tsquery('" + tsquery + "')"
sqlQuery = sqlQuery + " WHERE to_tsvector(" + tsvector + ") @@ to_tsquery('english','" + tsquery + "')"
def fullTextSearch(self,request): # addresses/fullTextSearch?fields=street,city,housenumber&query=ch%20du%2028&tolerance=0.005&easting=6.62379551&northing=46.51687241&limit=20&distinct=true # Read request parameters fields = request.params['fields']
responseElements = responseText.split('\'') housenumber = responseElements[7] street = responseElements[3] postcode = responseElements[5] city = responseElements[11]
responseElements = responseText.split('\n') for element in responseElements: if element.rfind('strname1') > -1: strname1_s = element.split('=') street = strname1_s[1].lstrip().lstrip('\'').rstrip().rstrip('\'') if element.rfind('plz4') > -1: plz4_s = element.split('=') postcode = plz4_s[1].lstrip().lstrip('\'').rstrip(...
def index(self): if 'latitude' in request.params and 'longitude' in request.params: latitude = float(request.params['latitude']) longitude = float(request.params['longitude']) if 'easting' in request.params: easting = float(request.params['easting']) if 'northing' in request.params: northing = float(request.params['nor...
tsvector = 'tsvector_street_housenumber_city'
tsvector = "to_tsvector('english', coalesce(street,'') || ' ' || coalesce(housenumber,'') || ' ' || coalesce(city,''))"
def index(self, format='json'): """GET /: return all features.""" # If no filter argument is passed to the protocol index method # then the default MapFish filter is used. This default filter # is constructed based on the box, lon, lat, tolerance GET # params. # # If you need your own filter with application-specific p...
tsvector = 'tsvector_street'
tsvector = "to_tsvector('english', coalesce(street,''))"
def index(self, format='json'): """GET /: return all features.""" # If no filter argument is passed to the protocol index method # then the default MapFish filter is used. This default filter # is constructed based on the box, lon, lat, tolerance GET # params. # # If you need your own filter with application-specific p...
limit = request.params['limit']
limit = int(request.params['limit'])
def fullTextSearch(self,request): # addresses/fullTextSearch?fields=street,city,housenumber&query=ch%20du%2028&tolerance=0.005&easting=6.62379551&northing=46.51687241&limit=20&distinct=true # Read request parameters fields = request.params['fields']
yield UInt16(self, "left", "Text Grid Left") yield UInt16(self, "top", "Text Grid Top") yield UInt16(self, "width", "Text Grid Width") yield UInt16(self, "height", "Text Grid Height")
yield UInt16(parent, "left", "Text Grid Left") yield UInt16(parent, "top", "Text Grid Top") yield UInt16(parent, "width", "Text Grid Width") yield UInt16(parent, "height", "Text Grid Height")
def parseTextExtension(parent): yield UInt8(parent, "block_size", "Block Size") yield UInt16(self, "left", "Text Grid Left") yield UInt16(self, "top", "Text Grid Top") yield UInt16(self, "width", "Text Grid Width") yield UInt16(self, "height", "Text Grid Height") yield UInt8(parent, "cell_width", "Character Cell Width"...
cvt_time=lambda v:datetime(2001,1,1) + timedelta(seconds=v)
def cvt_time(v): v=timedelta(seconds=v) epoch2001 = datetime(2001,1,1) epoch1970 = datetime(1970,1,1) if (epoch2001 + v - datetime.today()).days > 5*365: return epoch1970 + v return epoch2001 + v
def createFields(self): yield Enum(Bits(self, "marker_type", 4), {0: "Simple", 1: "Int", 2: "Real", 3: "Date", 4: "Data", 5: "ASCII String", 6: "UTF-16-BE String", 8: "UID", 10: "Array", 13: "Dict",}) markertype = self['marker_type'].value if markertype == 0: # Simple (Null) yield Enum(Bits(self, "value", 4), {0: "Null...
self.xml=lambda prefix:prefix + "<date>%s</date>"%(cvt_time(self['value'].value).isoformat())
self.xml=lambda prefix:prefix + "<date>%sZ</date>"%(cvt_time(self['value'].value).isoformat())
def createFields(self): yield Enum(Bits(self, "marker_type", 4), {0: "Simple", 1: "Int", 2: "Real", 3: "Date", 4: "Data", 5: "ASCII String", 6: "UTF-16-BE String", 8: "UID", 10: "Array", 13: "Dict",}) markertype = self['marker_type'].value if markertype == 0: # Simple (Null) yield Enum(Bits(self, "value", 4), {0: "Null...
self.xml=lambda prefix:prefix + "<string>%s</string>"%(self['value'].value.encode('iso-8859-1'))
self.xml=lambda prefix:prefix + "<string>%s</string>"%(self['value'].value.replace('&','&amp;').encode('iso-8859-1'))
def createFields(self): yield Enum(Bits(self, "marker_type", 4), {0: "Simple", 1: "Int", 2: "Real", 3: "Date", 4: "Data", 5: "ASCII String", 6: "UTF-16-BE String", 8: "UID", 10: "Array", 13: "Dict",}) markertype = self['marker_type'].value if markertype == 0: # Simple (Null) yield Enum(Bits(self, "value", 4), {0: "Null...
self.xml=lambda prefix:prefix + "<string>%s</string>"%(self['value'].value.encode('utf-8'))
self.xml=lambda prefix:prefix + "<string>%s</string>"%(self['value'].value.replace('&','&amp;').encode('utf-8'))
def createFields(self): yield Enum(Bits(self, "marker_type", 4), {0: "Simple", 1: "Int", 2: "Real", 3: "Date", 4: "Data", 5: "ASCII String", 6: "UTF-16-BE String", 8: "UID", 10: "Array", 13: "Dict",}) markertype = self['marker_type'].value if markertype == 0: # Simple (Null) yield Enum(Bits(self, "value", 4), {0: "Null...
while field:
while field is not None:
def _getPath(self): if not self._parent: return '/' names = [] field = self while field: names.append(field._name) field = field._parent names[-1] = '' return '/'.join(reversed(names))
addr_text = ''
addr_text_list = []
def update_addr_view(self): addr_text = '' for i in xrange(self.view.get_height_chars()): addr_text += self.format_addr(self.pos+i*self.view.get_width_chars())+'\n' self.view.addr_view.SetValue(addr_text)
addr_text += self.format_addr(self.pos+i*self.view.get_width_chars())+'\n' self.view.addr_view.SetValue(addr_text)
addr_text_list.append( self.format_addr(self.pos+i*self.view.get_width_chars())+'\n') self.view.addr_view.SetValue(''.join(addr_text_list))
def update_addr_view(self): addr_text = '' for i in xrange(self.view.get_height_chars()): addr_text += self.format_addr(self.pos+i*self.view.get_width_chars())+'\n' self.view.addr_view.SetValue(addr_text)
self.trackCommon(track, video)
def processVideo(self, track): video = Metadata(self) try: self.trackCommon(track, video) video.compression = track["CodecID/string"].value if "Video" in track: video.width = track["Video/PixelWidth/unsigned"].value video.height = track["Video/PixelHeight/unsigned"].value except MissingField: pass self.addGroup("video[...
try: self.trackCommon(track, audio) if "Audio" in track: audio.sample_rate = track["Audio/SamplingFrequency/float"].value
self.trackCommon(track, audio) if "Audio" in track: frequency = self.getDouble(track, "Audio/SamplingFrequency") if frequency is not None: audio.sample_rate = frequency if "Audio/Channels/unsigned" in track:
def processAudio(self, track): audio = Metadata(self) try: self.trackCommon(track, audio) if "Audio" in track: audio.sample_rate = track["Audio/SamplingFrequency/float"].value audio.nb_channel = track["Audio/Channels/unsigned"].value audio.compression = track["CodecID/string"].value except MissingField: pass self.addGr...
except MissingField: pass
def processAudio(self, track): audio = Metadata(self) try: self.trackCommon(track, audio) if "Audio" in track: audio.sample_rate = track["Audio/SamplingFrequency/float"].value audio.nb_channel = track["Audio/Channels/unsigned"].value audio.compression = track["CodecID/string"].value except MissingField: pass self.addGr...
self.trackCommon(track, sub)
def processSubtitle(self, track): sub = Metadata(self) try: self.trackCommon(track, sub) sub.compression = track["CodecID/string"].value except MissingField: pass self.addGroup("subtitle[]", sub, "Subtitle")
@fault_tolerant def readDuration(self, duration, timecode_scale): seconds = duration * timecode_scale self.duration = timedelta(seconds=seconds)
def processSimpleTag(self, tag): if "TagName/unicode" not in tag \ or "TagString/unicode" not in tag: return name = tag["TagName/unicode"].value if name not in self.tag_key: return key = self.tag_key[name] value = tag["TagString/unicode"].value setattr(self, key, value)
timecode_scale = info["TimecodeScale/unsigned"].value * 1e-9 if "Duration/float" in info: self.readDuration(info["Duration/float"].value, timecode_scale) elif "Duration/double" in info: self.readDuration(info["Duration/double"].value, timecode_scale)
duration = self.getDouble(info, "Duration") if duration is not None: try: seconds = duration * info["TimecodeScale/unsigned"].value * 1e-9 self.duration = timedelta(seconds=seconds) except OverflowError: pass
def processInfo(self, info): if "TimecodeScale/unsigned" in info: timecode_scale = info["TimecodeScale/unsigned"].value * 1e-9 if "Duration/float" in info: self.readDuration(info["Duration/float"].value, timecode_scale) elif "Duration/double" in info: self.readDuration(info["Duration/double"].value, timecode_scale) if ...
"stbl": (AtomList, "stbl", ""),
"stbl": (AtomList, "stbl", "Sample Table"), "stco": (STCO, "stsd", "Sample Table Chunk Offset"), "stsd": (STSD, "stsd", "Sample Table Sample Description"), "stss": (STSS, "stss", "Sample Table Sync Samples"), "stsz": (STSZ, "stsz", "Sample Table Sizes"),
def createFields(self): yield UInt32(self, "unk") yield AtomList(self, "tags")
"file_ext": ("mka", "mkv"),
"file_ext": ("mka", "mkv", "webm"),
def createFields(self): yield RawInt(self, 'id') yield Unsigned(self, 'size') for val in self.val[1:]: if callable(val): yield val(self) else: while not self.eof: yield EBML(self, val)
return False return self.stream.searchBytes('\x42\x82\x88matroska', 5*8, first._size) is not None
return "First chunk size is invalid" if self[0]['DocType/string'].value not in ('matroska', 'webm'): return "Stream isn't a matroska document." return True
def validate(self): if self.stream.readBits(0, 32, self.endian) != self.EBML_SIGNATURE: return False try: first = self[0] except ParserError: return False if None < self._size < first._size: return False return self.stream.searchBytes('\x42\x82\x88matroska', 5*8, first._size) is not None
if hdr['DocType/string'].value != 'matroska': raise ParserError("Stream isn't a matroska document.")
def createFields(self): hdr = EBML(self, ebml) yield hdr if hdr['DocType/string'].value != 'matroska': raise ParserError("Stream isn't a matroska document.")
yield UInt32(parent, "gamma", "Gamma (x10,000)")
yield UInt32(parent, "gamma", "Gamma (x100,000)")
def gammaParse(parent): yield UInt32(parent, "gamma", "Gamma (x10,000)")
return float(parent["gamma"].value) / 10000
return float(parent["gamma"].value) / 100000
def gammaValue(parent): return float(parent["gamma"].value) / 10000
if index+3 < len(text) \
elif index+3 < len(text) \
def parseRange(text, start): r""" >>> parseRange('[a]b', 1) (<RegexRange '[a]'>, 3) >>> parseRange('[a-z]b', 1) (<RegexRange '[a-z]'>, 5) >>> parseRange('[^a-z-]b', 1) (<RegexRange '[^a-z-]'>, 7) >>> parseRange('[^]-]b', 1) (<RegexRange '[^]-]'>, 5) """ index = start char_range = [] exclude = False if text[index] == '^...
if "Duration/float" in info \ and "TimecodeScale/unsigned" in info \ and 0 < info["Duration/float"].value: try: seconds = info["Duration/float"].value * info["TimecodeScale/unsigned"].value * 1e-9 self.duration = timedelta(seconds=seconds) except OverflowError: pass
if "TimecodeScale/unsigned" in info: timecode_scale = info["TimecodeScale/unsigned"].value * 1e-9 if "Duration/float" in info: self.readDuration(info["Duration/float"].value, timecode_scale) elif "Duration/double" in info: self.readDuration(info["Duration/double"].value, timecode_scale)
def processInfo(self, info): if "Duration/float" in info \ and "TimecodeScale/unsigned" in info \ and 0 < info["Duration/float"].value: try: seconds = info["Duration/float"].value * info["TimecodeScale/unsigned"].value * 1e-9 self.duration = timedelta(seconds=seconds) except OverflowError: # Catch OverflowError for tim...
install_options["install_requires"] = "hachoir-core>=1.2.1"
install_options["install_requires"] = "hachoir-core>=1.3"
def main(): if "--setuptools" in argv: argv.remove("--setuptools") from setuptools import setup use_setuptools = True else: from distutils.core import setup use_setuptools = False hachoir_parser = load_source("version", path.join("hachoir_parser", "version.py")) PACKAGES = {"hachoir_parser": "hachoir_parser"} for nam...
title=title, desc=desc, tags=tags, search_hidden=not visible, safety=safety, is_public=is_public, is_family=is_family, is_friend=is_friend, content_type=content_type)
title=title, desc=desc, tags=tags, search_hidden=not visible, safety=safety, is_public=is_public, is_family=is_family, is_friend=is_friend, content_type=content_type, progress_tracker=self.upload_progress_tracker)
def upload(self, response=None): """Upload worker function, called by the File->Upload callback. As this calls itself in the deferred callback, it takes a response argument."""
search_hidden=not visible, safety=safety, is_public=is_public, is_family=is_family, is_friend=is_friend, content_type=content_type)
search_hidden=not visible, safety=safety, is_public=is_public, is_family=is_family, is_friend=is_friend, content_type=content_type, progress_tracker=self.upload_progress_tracker)
def upload(self, response=None): """Upload worker function, called by the File->Upload callback. As this calls itself in the deferred callback, it takes a response argument."""
lock = "org.gtk.PyUnique.lock"
lock = "%s.lock" % name
def __init__(self, name, startup_id=None): gobject.GObject.__init__(self) self._is_running = False self._name = name self._screen = gdk.screen_get_default()
self._check_for_errors(stderr)
def _download(self): self.log = '' self.information['status'] = DownloadStatus.RUNNING if self.information['download_type'] == DownloadTypes.TORRENT: # download torrent if necessary torrent_filename = os.path.join(self._config.get('general', 'folder_new_otrkeys'), self.filename + '.torrent') if not os.path.exists(tor...
This path is by default <mfm_lib_path>/../data/ in trunk and /usr/share/mfm in an installed version but this path
This path is by default <otrverwaltung_lib_path>/../data/ in trunk and /usr/share/otrverwaltung in an installed version but this path
def getdatapath(*args): """Retrieve otrverwaltung data path This path is by default <mfm_lib_path>/../data/ in trunk and /usr/share/mfm in an installed version but this path is specified at installation time. """ return os.path.join(os.path.dirname(__file__), data_dir, *args)
self.combobox_archive.fill(archive_directory) self.combobox_archive.set_active(0) self.combobox_archive.connect('changed', self._on_combobox_archive_changed)
if action != Action.DECODE: self.combobox_archive.fill(archive_directory) self.combobox_archive.set_active(0) self.combobox_archive.connect('changed', self._on_combobox_archive_changed)
def _run(self, file_conclusions, action, rename_by_schema, archive_directory): self.action = action self.rename_by_schema = rename_by_schema self.__file_conclusions = file_conclusions self.forward_clicks = 0 self.show_all() self.combobox_archive.fill(archive_directory) self.combobox_archive.set_active(0) self.combobo...
self.builder.get_object('button_play_cut').props.visible = cut_ok
self.builder.get_object('button_play_cut').props.visible = cut_ok self.builder.get_object('box_archive').props.visible = cut_ok
def show_conclusion(self, new_iter): self.conclusion_iter = new_iter self.file_conclusion = self.__file_conclusions[self.conclusion_iter] self.builder.get_object('label_count').set_text("Zeige Datei %s/%s" % (str(new_iter + 1), len(self.__file_conclusions)))
url = "%sgetxml.php?ofsb=%s" % (server, str(size))
urls = ["%sgetxml.php?ofsb=%s" % (server, str(size)), "%sgetxml.php?ofsb=%s" % (server, str((size+2*1024**3)%(4*1024**3)- 2*1024**3))]
def download_cutlists(filename, server, choose_cutlists_by, cutlist_mp4_as_hq, error_cb=None, cutlist_found_cb=None): """ Downloads all cutlists for the given file. filename - movie filename server - cutlist server choose_cutlists_by - 0 by size, 1 by name error_cb - callback: an err...
url = "%sgetxml.php?name=%s" % (server, root) print url try: handle = urllib.urlopen(url) except IOError: if error_cb: error_cb("Verbindungsprobleme") return "Verbindungsprobleme", None
urls = ["%sgetxml.php?name=%s" % (server, root)] cutlists = [] for url in urls: print "[Cutlists] Download by : %s" % url try: handle = urllib.urlopen(url) except IOError: if error_cb: error_cb("Verbindungsprobleme") return "Verbindungsprobleme", None try: dom_cutlists = xml.dom.minidom.parse(handle) handle.close() ...
def download_cutlists(filename, server, choose_cutlists_by, cutlist_mp4_as_hq, error_cb=None, cutlist_found_cb=None): """ Downloads all cutlists for the given file. filename - movie filename server - cutlist server choose_cutlists_by - 0 by size, 1 by name error_cb - callback: an err...
try: dom_cutlists = xml.dom.minidom.parse(handle) handle.close() dom_cutlists = dom_cutlists.getElementsByTagName('cutlist') except: if error_cb: error_cb("Keine Cutlists gefunden") return "Keine Cutlists gefunden", None cutlists = [] for cutlist in dom_cutlists: c = Cutlist() c.id = __read_v...
cutlists.append(c)
def download_cutlists(filename, server, choose_cutlists_by, cutlist_mp4_as_hq, error_cb=None, cutlist_found_cb=None): """ Downloads all cutlists for the given file. filename - movie filename server - cutlist server choose_cutlists_by - 0 by size, 1 by name error_cb - callback: an err...
def foreach(model, path, iter, data=None): index = model.get_value(iter, 0) stamp = self.app.planned_broadcasts[index].datetime if stamp < now: selection.select_iter(iter) self.builder.get_object('treeview_planning').get_model().foreach(foreach)
for row in self.builder.get_object('treeview_planning').get_model(): if row[0].datetime < now: selection.select_iter(row.iter)
def foreach(model, path, iter, data=None): index = model.get_value(iter, 0) stamp = self.app.planned_broadcasts[index].datetime
return "%s %s" % (self.user.username, self.group)
if self.user: username = self.user.username else: username = 'anonymous return "%s %s" % (username, self.group)
def __unicode__(self): return "%s %s" % (self.user.username, self.group)
raise
if settings.DEBUG: raise l.warning("Can't find the GoalType named %s" % goal_name)
def record(cls, goal_name, experiment_user): try: return cls._record(goal_name, experiment_user) except GoalType.DoesNotExist: raise except Exception, e: l.error("Unexpected exception in GoalRecord.record:\n" "%s" % traceback.format_exc)
goal_types = [GoalType.objects.create(name=i) for i in range(3)]
goal_types = [GoalType.objects.create(name=str(i)) for i in range(3)]
def testParticipantConversionCalculator(self): goal_types = [GoalType.objects.create(name=i) for i in range(3)] anonymous_visitor = AnonymousVisitor.objects.create() participant = self.create_participant( anonymous_visitor=anonymous_visitor, experiment=self.experiment, enrollment_date=self.experiment.start_date + timed...
l.error("Unexpected exception in GoalRecord.record:\n" "%s" % traceback.format_exc)
l.exception("Unexpected exception in GoalRecord.record")
def record(cls, goal_name, experiment_user): try: return cls._record(goal_name, experiment_user) except GoalType.DoesNotExist: if settings.DEBUG: raise l.warning("Can't find the GoalType named %s" % goal_name) except Exception, e: l.error("Unexpected exception in GoalRecord.record:\n" "%s" % traceback.format_exc)
scores a, and b. From Numerical Recipies, p.483. If printit=1, results are printed to the screen. If printit='filename', the results are output to 'filename' using the given writemode (default=append). Returns t-value, and prob. Originally written by Gary Strangman. Usage: lttest_ind(a,b,printit=0,name1='Samp1'...
scores a, and b. Returns t-value, and prob. Originally written by Gary Strangman. Usage: lttest_ind(a,b)
def ttest_ind(a, b): """ Calculates the t-obtained T-test on TWO INDEPENDENT samples of scores a, and b. From Numerical Recipies, p.483. If printit=1, results are printed to the screen. If printit='filename', the results are output to 'filename' using the given writemode (default=append). Returns t-value, and prob....
x1 = mean(a) x2 = mean(b) v1 = stdev(a)**2 v2 = stdev(b)**2 n1 = len(a) n2 = len(b)
x1, x2 = mean(a), mean(b) v1, v2 = stdev(a)**2, stdev(b)**2 n1, n2 = len(a), len(b)
def ttest_ind(a, b): """ Calculates the t-obtained T-test on TWO INDEPENDENT samples of scores a, and b. From Numerical Recipies, p.483. If printit=1, results are printed to the screen. If printit='filename', the results are output to 'filename' using the given writemode (default=append). Returns t-value, and prob....
svar = ((n1-1)*v1+(n2-1)*v2)/float(df) t = (x1-x2)/sqrt(svar*(1.0/n1 + 1.0/n2))
try: svar = ((n1-1)*v1+(n2-1)*v2)/float(df) except ZeroDivisionError: return float('nan'), float('nan') try: t = (x1-x2)/sqrt(svar*(1.0/n1 + 1.0/n2)) except ZeroDivisionError: t = 1.0
def ttest_ind(a, b): """ Calculates the t-obtained T-test on TWO INDEPENDENT samples of scores a, and b. From Numerical Recipies, p.483. If printit=1, results are printed to the screen. If printit='filename', the results are output to 'filename' using the given writemode (default=append). Returns t-value, and prob....
arg = len(names)
arg = len(proposals)
def code_assist(self, prefix): proposals = self._calculate_proposals() if prefix is not None: arg = self.env.prefix_value(prefix) if arg == 0: arg = len(names) common_start = self._calculate_prefix(proposals[:arg]) self.env.insert(common_start[self.offset - self.starting_offset:]) self._starting = common_start self._of...
proposals = codeassist.sorted_proposals(proposals)
if self.env.get('sorted_completions', True): proposals = codeassist.sorted_proposals(proposals)
def _calculate_proposals(self): self.interface._check_project() resource = self.interface.resource maxfixes = self.env.get('codeassist_maxfixes') proposals = codeassist.code_assist( self.interface.project, self.source, self.offset, resource, maxfixes=maxfixes) proposals = codeassist.sorted_proposals(proposals) if self....
response = self.requestor.request('execute_cql_query', request_params)
try: response = self.requestor.request('execute_cql_query', request_params) except AvroRemoteException, are: raise CQLException(are)
def execute(self, query, compression=None): compress = compression is None and DEFAULT_COMPRESSION \ or compression.upper() if not compress in COMPRESSION_SCHEMES: raise InvalidCompressionScheme(compress) compressed_query = Connection.compress_query(query, compress) request_params = dict(query=compressed_query, compre...
newSnpData = SNPData(col_id_ls=copy.deepcopy(snpData.col_id_ls), row_id_ls=[]) newSnpData.data_matrix = num.zeros([no_of_rows, no_of_cols], num.int8)
new_col_id_ls = copy.deepcopy(snpData.col_id_ls) new_row_id_ls = [] new_data_matrix = num.zeros([no_of_rows, no_of_cols], num.int8)
def keepRowsByRowID(cls, snpData, row_id_ls): """ 2009-05-19 keep certain rows in snpData given row_id_ls """ sys.stderr.write("Keeping rows given row_id_ls ...") no_of_rows = len(row_id_ls) row_id_wanted_set = set(row_id_ls) no_of_cols = len(snpData.col_id_ls) newSnpData = SNPData(col_id_ls=copy.deepcopy(snpData.col_...
newSnpData.row_id_ls.append(row_id) newSnpData.data_matrix[row_index] = snpData.data_matrix[i]
new_row_id_ls.append(row_id) new_data_matrix[row_index] = snpData.data_matrix[i]
def keepRowsByRowID(cls, snpData, row_id_ls): """ 2009-05-19 keep certain rows in snpData given row_id_ls """ sys.stderr.write("Keeping rows given row_id_ls ...") no_of_rows = len(row_id_ls) row_id_wanted_set = set(row_id_ls) no_of_cols = len(snpData.col_id_ls) newSnpData = SNPData(col_id_ls=copy.deepcopy(snpData.col_...
report=1, run_type=1): """
cofactor_phenotype_id_ls=[], report=1, run_type=1,): """ 2010-1-11 add argument cofactor_phenotype_id_ls to have the functionality of treating some phenotypes as cofactors
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.)
one phenotype at a time: 1. create a new SNP matrix which includes accessions whose phenotypes (this phenotype + cofactor_phenotype_id_ls) are non-NA 2. one SNP at a time 1. add cofactor SNP matrix if cofactors are present 2. add cofactor phenotype matrix if cofactor_phenotype_id_ls exist 3. run association parameter ...
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
chromosome, start_pos = start_snp.split('_')[:2]
start_chr, start_pos = start_snp.split('_')[:2] start_chr = int(start_chr)
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
stop_pos = int(stop_snp.split('_')[1])
stop_chr, stop_pos = stop_snp.split('_')[:2] stop_chr = int(stop_chr) stop_pos = int(stop_pos)
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
if not numpy.isnan(phenotype_ls[i]):
this_row_has_NA_phenotype = False if cofactor_phenotype_index_ls: for phenotype_index in cofactor_phenotype_index_ls: if numpy.isnan(initData.phenData.data_matrix[i, phenotype_index]): this_row_has_NA_phenotype = True break if numpy.isnan(phenotype_ls[i]): this_row_has_NA_phenotype = True if not this_row_has_NA_phenot...
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
if chr==chromosome and pos>=start_pos and pos<=stop_pos:
if chr>=start_chr and chr<=stop_chr and pos>=start_pos and pos<=stop_pos:
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
phenotype_method_id_ls = [43]
phenotype_method_id_ls = [285]
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
GWA.cofactorLM(genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=cofactors)
cofactor_phenotype_id_ls = [77] GWA.cofactorLM(genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, \ cofactors=cofactors, cofactor_phenotype_id_ls=cofactor_phenotype_id_ls)
def cofactorLM(cls, genotype_fname, phenotype_fname, phenotype_method_id_ls, output_fname_prefix, start_snp, stop_snp, cofactors=[],\ report=1, run_type=1): """ 2009-8-26 run_type 1: pure linear model by python run_type 2: EMMA run_type 3: pure linear model by R (Field test shows run_type 3 is same as 1.) start_snp an...
max_diff_perc=0.10, min_no_of_probes=5, count_embedded_segment_as_match=False): """
max_diff_perc=0.10, min_no_of_probes=5, count_embedded_segment_as_match=False, \ min_reciprocal_overlap=0.6, report=True): """ 2010-1-26 value of the ecotype_id2cnv_qc_call_data dictionary is a RBDict (RBTree dictionary) structure. 2009-12-8 add argument min_reciprocal_overlap
def compareCNVSegmentsAgainstQCHandler(cls, input_fname_ls, ecotype_id2cnv_qc_call_data, function_handler, param_obj, \ deletion_cutoff=None, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5, count_embedded_segment_as_match=False): """ 2009-11-4 a general handler to compare CNV segments from input_fnam...
if boundary_diff1<=max_boundary_diff and boundary_diff2<=max_boundary_diff and diff1_perc<=max_diff_perc and \ diff2_perc<=max_diff_perc:
is_overlap = is_reciprocal_overlap([segment_start_pos, segment_stop_pos], [qc_start, qc_stop], \ min_reciprocal_overlap=min_reciprocal_overlap) if is_overlap:
def compareCNVSegmentsAgainstQCHandler(cls, input_fname_ls, ecotype_id2cnv_qc_call_data, function_handler, param_obj, \ deletion_cutoff=None, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5, count_embedded_segment_as_match=False): """ 2009-11-4 a general handler to compare CNV segments from input_fnam...
elif count_embedded_segment_as_match and segment_start_pos>=qc_start and segment_stop_pos<=qc_stop: no_of_valid_deletions += 1 valid_match = True
def compareCNVSegmentsAgainstQCHandler(cls, input_fname_ls, ecotype_id2cnv_qc_call_data, function_handler, param_obj, \ deletion_cutoff=None, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5, count_embedded_segment_as_match=False): """ 2009-11-4 a general handler to compare CNV segments from input_fnam...
cnv_segment_obj = PassingData(ecotype_id=cnv_ecotype_id, start_probe=start_probe, stop_probe=stop_probe,\ no_of_probes=no_of_probes, amplitude=amplitude, segment_length=segment_length,\ segment_chromosome=segment_chromosome, ) function_handler(cnv_segment_obj, cnv_qc_call, param_obj)
function_handler(param_obj, cnv_segment_obj, cnv_qc_call, )
def compareCNVSegmentsAgainstQCHandler(cls, input_fname_ls, ecotype_id2cnv_qc_call_data, function_handler, param_obj, \ deletion_cutoff=None, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5, count_embedded_segment_as_match=False): """ 2009-11-4 a general handler to compare CNV segments from input_fnam...
if counter%10000==0:
""" if report and counter%10000==0:
def compareCNVSegmentsAgainstQCHandler(cls, input_fname_ls, ecotype_id2cnv_qc_call_data, function_handler, param_obj, \ deletion_cutoff=None, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5, count_embedded_segment_as_match=False): """ 2009-11-4 a general handler to compare CNV segments from input_fnam...
def getCNVQCDataFromDB(cls, data_source_id=1, ecotype_id=None, cnv_type_id=1, \ min_QC_segment_size=200, min_no_of_probes=None): """
def getCNVQCDataFromDB(cls, data_source_id=1, ecotype_id=None, cnv_type_id=None, \ min_QC_segment_size=None, min_no_of_probes=None, min_reciprocal_overlap=0.6): """ 2010-1-26 replace the list structure of cnv_qc_call_data in ecotype_id2cnv_qc_call_data with binary_tree structure 2009-12-9 add no_of_probes_covered into ...
def getCNVQCDataFromDB(cls, data_source_id=1, ecotype_id=None, cnv_type_id=1, \ min_QC_segment_size=200, min_no_of_probes=None): """ 2009-11-4 get CNV QC data from database """ sys.stderr.write("Getting CNV QC data ... \n") import Stock_250kDB sql_string = "select a.ecotype_id, c.chromosome, c.start, c.stop, c.size_aff...
sql_string = "select a.ecotype_id, c.chromosome, c.start, c.stop, c.size_affected, c.id from %s c,\ %s a where c.accession_id=a.id and a.data_source_id=%s and c.size_affected>=%s \ and c.cnv_type_id=%s"%\ (Stock_250kDB.CNVQCCalls.table.name, Stock_250kDB.CNVQCAccession.table.name, data_source_id,\ min_QC_segment_size, ...
sql_string = "select a.ecotype_id, c.chromosome, c.start, c.stop, c.size_affected, c.no_of_probes_covered, c.copy_number, c.id from %s c,\ %s a where c.accession_id=a.id and a.data_source_id=%s order by RAND()"%\ (Stock_250kDB.CNVQCCalls.table.name, Stock_250kDB.CNVQCAccession.table.name, data_source_id) if cnv_type_i...
def getCNVQCDataFromDB(cls, data_source_id=1, ecotype_id=None, cnv_type_id=1, \ min_QC_segment_size=200, min_no_of_probes=None): """ 2009-11-4 get CNV QC data from database """ sys.stderr.write("Getting CNV QC data ... \n") import Stock_250kDB sql_string = "select a.ecotype_id, c.chromosome, c.start, c.stop, c.size_aff...
ecotype_id2cnv_qc_call_data[row.ecotype_id] = [] cnv_qc_call_data = ecotype_id2cnv_qc_call_data[row.ecotype_id] cnv_qc_call_data.append((row.chromosome, row.start, row.stop, row.size_affected, row.id))
ecotype_id2cnv_qc_call_data[row.ecotype_id] = RBDict() segmentKey = CNVSegmentBinarySearchTreeKey(chromosome=row.chromosome, span_ls=[row.start, row.stop], \ min_reciprocal_overlap=min_reciprocal_overlap) ecotype_id2cnv_qc_call_data[row.ecotype_id][segmentKey] = (row.chromosome, row.start, row.stop, row.size_affected,...
def getCNVQCDataFromDB(cls, data_source_id=1, ecotype_id=None, cnv_type_id=1, \ min_QC_segment_size=200, min_no_of_probes=None): """ 2009-11-4 get CNV QC data from database """ sys.stderr.write("Getting CNV QC data ... \n") import Stock_250kDB sql_string = "select a.ecotype_id, c.chromosome, c.start, c.stop, c.size_aff...
for ecotype_id, cnv_qc_call_data in ecotype_id2cnv_qc_call_data.iteritems(): cnv_qc_call_data.sort() ecotype_id2cnv_qc_call_data[ecotype_id] = cnv_qc_call_data sys.stderr.write("%s cnv qc calls for %s ecotypes. Done.\n"%(count, len(ecotype_id2cnv_qc_call_data)))
import math for ecotype_id, tree in ecotype_id2cnv_qc_call_data.iteritems(): print "\tDepth of Ecotype %s's tree: %d" % (ecotype_id, tree.depth()) print "\tOptimum Depth: %f (%d) (%f%% depth efficiency)" % (tree.optimumdepth(), math.ceil(tree.optimumdepth()), math.ceil(tree.optimumdepth()) / tree.depth()) sys.stderr...
def getCNVQCDataFromDB(cls, data_source_id=1, ecotype_id=None, cnv_type_id=1, \ min_QC_segment_size=200, min_no_of_probes=None): """ 2009-11-4 get CNV QC data from database """ sys.stderr.write("Getting CNV QC data ... \n") import Stock_250kDB sql_string = "select a.ecotype_id, c.chromosome, c.start, c.stop, c.size_aff...
def countMatchedDeletionsFunctor(cls, cnv_segment_obj, cnv_qc_call, param_obj): """
def countMatchedDeletionsFunctor(cls, param_obj, cnv_segment_obj=None, cnv_qc_call=None): """ 2009-12-9 store qc data in param_obj.array_id2qc_data
def countMatchedDeletionsFunctor(cls, cnv_segment_obj, cnv_qc_call, param_obj): """ 2009-11-4 a functor to be called in """ if not hasattr(param_obj, 'no_of_valid_deletions'): setattr(param_obj, 'no_of_valid_deletions', 0) qc_chromosome, qc_start, qc_stop = cnv_qc_call[:3] cnv_qc_call_id = cnv_qc_call[-1] param_obj.cnv...
qc_chromosome, qc_start, qc_stop = cnv_qc_call[:3] cnv_qc_call_id = cnv_qc_call[-1] param_obj.cnv_qc_call_id_set.add(cnv_qc_call_id) param_obj.no_of_valid_deletions += 1
if not hasattr(param_obj, "array_id2qc_data"): param_obj.array_id2qc_data = {} if not hasattr(param_obj, "array_id2no_of_probes2qc_data"): param_obj.array_id2no_of_probes2qc_data = {} if not hasattr(param_obj, "array_id2qc_no_of_probes2qc_data"): param_obj.array_id2qc_no_of_probes2qc_data = {} array_id = cnv_segment_o...
def countMatchedDeletionsFunctor(cls, cnv_segment_obj, cnv_qc_call, param_obj): """ 2009-11-4 a functor to be called in """ if not hasattr(param_obj, 'no_of_valid_deletions'): setattr(param_obj, 'no_of_valid_deletions', 0) qc_chromosome, qc_start, qc_stop = cnv_qc_call[:3] cnv_qc_call_id = cnv_qc_call[-1] param_obj.cnv...
no_of_QCCalls_matched = len(param_obj.cnv_qc_call_id_set) no_of_total_QCCalls = sum(map(len, param_obj.ecotype_id2cnv_qc_call_data.values())) false_negative_rate = (no_of_total_QCCalls-no_of_QCCalls_matched)/float(no_of_total_QCCalls) sys.stderr.write("False negative rate: %s/%s(%s).\n"%(no_of_total_QCCalls-no_of_QCCal...
for array_id, qc_data in param_obj.array_id2qc_data.iteritems(): no_of_QCCalls_matched = len(qc_data.cnv_qc_call_id_set) no_of_total_QCCalls = len(param_obj.ecotype_id2cnv_qc_call_data[qc_data.ecotype_id]) false_negative_rate = (no_of_total_QCCalls-no_of_QCCalls_matched)/float(no_of_total_QCCalls) sys.stderr.write("Arr...
def outputFalseNegativeRate(cls, param_obj): """ 2009-11-4 """ no_of_QCCalls_matched = len(param_obj.cnv_qc_call_id_set) no_of_total_QCCalls = sum(map(len, param_obj.ecotype_id2cnv_qc_call_data.values())) false_negative_rate = (no_of_total_QCCalls-no_of_QCCalls_matched)/float(no_of_total_QCCalls) sys.stderr.write("Fals...
no_of_valid_deletions = param_obj.no_of_valid_deletions no_of_deletions = param_obj.no_of_deletions no_of_non_valid_deletions = no_of_deletions-no_of_valid_deletions false_positive_rate = no_of_non_valid_deletions/float(no_of_deletions) sys.stderr.write("False positive rate: %s/%s(%s).\n"%\ (no_of_non_valid_deletions, ...
for array_id, qc_data in param_obj.array_id2qc_data.iteritems(): no_of_valid_deletions = qc_data.no_of_valid_deletions no_of_deletions = qc_data.no_of_deletions no_of_non_valid_deletions = no_of_deletions-no_of_valid_deletions false_positive_rate = no_of_non_valid_deletions/float(no_of_deletions) sys.stderr.write("Arra...
def outputFalsePositiveRate(cls, param_obj): """ 2009-11-4 """ no_of_valid_deletions = param_obj.no_of_valid_deletions no_of_deletions = param_obj.no_of_deletions no_of_non_valid_deletions = no_of_deletions-no_of_valid_deletions false_positive_rate = no_of_non_valid_deletions/float(no_of_deletions) sys.stderr.write("Fa...
count_embedded_segment_as_match=True): """
count_embedded_segment_as_match=True, min_reciprocal_overlap=0.6): """ 2010-1-26 pass min_reciprocal_overlap to cls.getCNVQCDataFromDB() 2009-12-9 calculate FNR for each class with same number of probes
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
ecotype_id2cnv_qc_call_data = cls.getCNVQCDataFromDB(data_source_id, ecotype_id, cnv_type_id, min_QC_segment_size, min_no_of_probes)
ecotype_id2cnv_qc_call_data = cls.getCNVQCDataFromDB(data_source_id, ecotype_id, cnv_type_id, min_QC_segment_size, min_no_of_probes,\ min_reciprocal_overlap=min_reciprocal_overlap)
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
param_obj = PassingData(no_of_valid_deletions=0, cnv_qc_call_id_set=set())
param_obj = PassingData(no_of_valid_deletions=0, cnv_qc_call_id_set=set(), array_id2qc_data={})
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
count_embedded_segment_as_match=count_embedded_segment_as_match) sys.stderr.write("For ecotype_id %s, data_source_id %s, min_QC_segment_size %s, deletion_cutoff: %s, min_no_of_probes: %s, max_boundary_diff: %s, max_diff_perc %s.\n"%\
count_embedded_segment_as_match=count_embedded_segment_as_match, \ min_reciprocal_overlap=min_reciprocal_overlap, report=False) sys.stderr.write("For ecotype_id %s, data_source_id %s, min_QC_segment_size %s, deletion_cutoff: %s, min_no_of_probes: %s, min_reciprocal_overlap: %s.\n"%\
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
data_source_id, min_QC_segment_size, deletion_cutoff, min_no_of_probes, max_boundary_diff, max_diff_perc))
data_source_id, min_QC_segment_size, deletion_cutoff, min_no_of_probes, min_reciprocal_overlap))
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
for max_boundary_diff in [10000]: for max_diff_perc in [0.20, 0.3]: CNV.countNoOfCNVDeletionsMatchQC(db_250k, input_fname_ls, ecotype_id=ecotype_id, data_source_id=data_source_id, \ cnv_type_id=1,\
for min_reciprocal_overlap in [0.4, 0.6, 0.8]: CNV.countNoOfCNVDeletionsMatchQC(db_250k, input_fname_ls, ecotype_id=ecotype_id, data_source_id=data_source_id, \ cnv_type_id=1,\
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
max_boundary_diff=max_boundary_diff, max_diff_perc=max_diff_perc, \
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
count_embedded_segment_as_match=count_embedded_segment_as_match) """ @classmethod def addAmplitudeFunctor(cls, cnv_segment_obj, cnv_qc_call, param_obj): """
count_embedded_segment_as_match=count_embedded_segment_as_match,\ min_reciprocal_overlap=min_reciprocal_overlap) input_fname_ls = [] for i in range(1,6): input_fname_ls.append(os.path.expanduser('~/mnt2/panfs/250k/CNV/call_method_48_CNV_intensity_QNorm_sub_ref_chr%s.GADA_A0.5T4M5.tsv'%i)) ecotype_id_data_source...
def countNoOfCNVDeletionsMatchQC(cls, db_250k, input_fname_ls, ecotype_id=6909, data_source_id=3, cnv_type_id=1, \ min_QC_segment_size=200, deletion_cutoff=-0.33, max_boundary_diff=10000, \ max_diff_perc=0.10, min_no_of_probes=5,\ count_embedded_segment_as_match=True): """ 2009-10-29 for all CNV deletions, check how ma...
qc_chromosome, qc_start, qc_stop = cnv_qc_call[:3] cnv_qc_call_id = cnv_qc_call[-1] param_obj.cnv_qc_call_id_set.add(cnv_qc_call_id) param_obj.amp_ls.append(cnv_segment_obj.amplitude)
if cnv_qc_call is not None: qc_chromosome, qc_start, qc_stop = cnv_qc_call[:3] cnv_qc_call_id = cnv_qc_call[-1] param_obj.cnv_qc_call_id_set.add(cnv_qc_call_id) param_obj.amp_ls.append(cnv_segment_obj.amplitude)
def addAmplitudeFunctor(cls, cnv_segment_obj, cnv_qc_call, param_obj): """ 2009-11-4 """ if not hasattr(param_obj, 'amp_ls'): setattr(param_obj, 'amp_ls', []) qc_chromosome, qc_start, qc_stop = cnv_qc_call[:3] cnv_qc_call_id = cnv_qc_call[-1] param_obj.cnv_qc_call_id_set.add(cnv_qc_call_id) param_obj.amp_ls.append(cnv_...
max_diff_perc=0.10, count_embedded_segment_as_match=True):
max_diff_perc=0.10, count_embedded_segment_as_match=True, min_reciprocal_overlap=0.6):
def drawHistOfAmpOfValidatedDeletions(cls, db_250k, input_fname_ls, output_fname_prefix, data_source_id=1, cnv_type_id=1, \ min_QC_segment_size=200, min_no_of_probes=5, max_boundary_diff=10000, \ max_diff_perc=0.10, count_embedded_segment_as_match=True): """ 2009-11-4 draw histogram of amplitude of segments who are val...
min_no_of_probes=min_no_of_probes)
min_no_of_probes=min_no_of_probes, \ min_reciprocal_overlap=min_reciprocal_overlap)
def drawHistOfAmpOfValidatedDeletions(cls, db_250k, input_fname_ls, output_fname_prefix, data_source_id=1, cnv_type_id=1, \ min_QC_segment_size=200, min_no_of_probes=5, max_boundary_diff=10000, \ max_diff_perc=0.10, count_embedded_segment_as_match=True): """ 2009-11-4 draw histogram of amplitude of segments who are val...
overlap_length = max(0, stop-self.start) - max(0, stop-self.stop) - max(0, start-self.start) overlap_length = float(overlap_length) overlap1 = overlap_length/(stop-start) overlap2 = overlap_length/self.segment_length if overlap1>=self.min_reciprocal_overlap and overlap2>=self.min_reciprocal_overlap:
is_overlap = is_reciprocal_overlap([start, stop], [self.start, self.stop], \ min_reciprocal_overlap=self.min_reciprocal_overlap) if is_overlap:
def addNewCNV(self, chromosome, start, stop, array_id=None): """ """ if self.chromosome is None: self.addOneCNV(chromosome, start, stop, array_id) elif self.chromosome is not None and chromosome!=self.chromosome: return False else: """ boundary_diff1 = abs(start-self.start) boundary_diff2 = abs(stop-self.stop) diff1_pe...
2 functions: 1. detect deletions. make sure the deletion is covered by the sequencing.
Two functions: 1. deletion_only=True. make sure the deletion is covered by the sequencing.
def discoverLerDeletionDuplication(cls, db_250k, ler_blast_result_fname, output_fname, deletion_only=True, min_no_of_matches=25): """ 2009-12-7 ler_blast_result_fname is the output of blasting all CNV probes against Ler contigs http://www.arabidopsis.org/browse/Cereon/index.jsp. 2 functions: 1. detect deletions. make s...
2. detect copy number changes. If two adjacent probes have different number of contigs, then it's a copy number change point.
2. deletion_only=False, detect copy number changes. If two adjacent probes have different number of contigs, then it's a copy number change point.
def discoverLerDeletionDuplication(cls, db_250k, ler_blast_result_fname, output_fname, deletion_only=True, min_no_of_matches=25): """ 2009-12-7 ler_blast_result_fname is the output of blasting all CNV probes against Ler contigs http://www.arabidopsis.org/browse/Cereon/index.jsp. 2 functions: 1. detect deletions. make s...
session = db_250k.session
def discoverLerDeletionDuplication(cls, db_250k, ler_blast_result_fname, output_fname, deletion_only=True, min_no_of_matches=25): """ 2009-12-7 ler_blast_result_fname is the output of blasting all CNV probes against Ler contigs http://www.arabidopsis.org/browse/Cereon/index.jsp. 2 functions: 1. detect deletions. make s...
snpData = SNPData(input_fname=inputFname, turn_into_array=1)
row_id_key_set = set([row_id1, row_id2]) snpData = SNPData(input_fname=inputFname, turn_into_array=1, row_id_key_set=row_id_key_set)
def cmpOneRowToTheOther(cls, inputFname, row_id1, row_id2): """ 2009-6-17 compare SNP data of one accession to the other in the same dataset """ sys.stderr.write("Comparing one row to the other ... \n") from pymodule import SNPData, TwoSNPData, PassingData snpData = SNPData(input_fname=inputFname, turn_into_array=1) tw...
inputFname = '/Network/Data/250k/db/dataset/call_method_29.tsv' row_id1 = ('6910', '62') row_id2 = ('8290', '181') AnalyzeSNPData.cmpOneRowToTheOther(inputFname, row_id1, row_id2)
inputFname = '/Network/Data/250k/db/dataset/call_method_29.tsv' row_id1 = ('6910', '62') row_id2 = ('8290', '181') AnalyzeSNPData.cmpOneRowToTheOther(inputFname, row_id1, row_id2) inputFname = os.path.expanduser('~/mnt2/panfs/NPUTE_data/input/250k_l3_y.85_20091208.tsv') row_id1 = ('7034', '1338') row_id2 = ('7035', '...
def cmpOneRowToTheOther(cls, inputFname, row_id1, row_id2): """ 2009-6-17 compare SNP data of one accession to the other in the same dataset """ sys.stderr.write("Comparing one row to the other ... \n") from pymodule import SNPData, TwoSNPData, PassingData snpData = SNPData(input_fname=inputFname, turn_into_array=1) tw...
ler_blast_result_fname = '/Network/Data/250k/tmp-dazhe/tair9_raw.csv' output_fname = '/tmp/Col-copy-number.tsv' CNV.discoverLerDeletionDuplication(db_250k, ler_blast_result_fname, output_fname, deletion_only=False) """ cnv_intensity_fname = os.path.expanduser('~/mnt2/panfs/250k/CNV/call_method_48_CNV_intensity.tsv') a...
ler_blast_result_fname = '/Network/Data/250k/tmp-dazhe/ler_raw_CNV_QC.csv' max_delta_ratio = 0.4 max_length_delta = 10000 for max_length_delta in range(1,7): max_length_delta = max_length_delta*10000 output_fname = '/tmp/Ler-span-over-Col-mdr%s-mld%s.tsv'%(max_delta_ratio, max_length_delta) CNV.discoverLerContigSpanOve...
def linkEcotypeIDFromSuziPhenotype(cls, fname_with_ID, fname_with_phenotype, output_fname): """ 2009-7-31 she gave me two files one has phenotype data and accession names but with no ecotype ID 2nd is a map from accession name to ecotype ID """ sys.stderr.write("Linking accession names to ecotype ID ... ") import csv i...
overlap1 = overlap_length/(qc_stop-qc_start) overlap2 = overlap_length/(segment_stop_pos-segment_start_pos)
overlap1 = overlap_length/(segment_stop_pos-segment_start_pos) overlap2 = overlap_length/(qc_stop-qc_start)
def get_overlap_ratio(span1_ls, span2_ls): """ 2009-12-13 calculate the two overlap ratios for two segments """ segment_start_pos, segment_stop_pos = span1_ls qc_start, qc_stop = span2_ls overlap_length = max(0, segment_stop_pos - qc_start) - max(0, segment_stop_pos - qc_stop) - max(0, segment_start_pos - qc_start) # a...
a key designed to represent a CNV segment in a binary search tree (BinarySearchTree.py), which could be used to do == or >, or < operators
a key designed to represent a CNV segment in the node of a binary search tree (BinarySearchTree.py) or RBTree (RBTree.py), It has custom comparison function based on the is_reciprocal_overlap() function.
def is_reciprocal_overlap(span1_ls, span2_ls, min_reciprocal_overlap=0.6): """ 2009-12-12 return True if both overlap ratios are above the min_reciprocal_overlap """ overlap1, overlap2 = get_overlap_ratio(span1_ls, span2_ls) if overlap1>=min_reciprocal_overlap and overlap2>=min_reciprocal_overlap: return True else: ret...
return self.span_ls[0]>=other.span_ls[0] and self.span_ls[1]<=other.span_ls[0]
return self.span_ls[0]<=other.span_ls[0] and self.span_ls[1]>=other.span_ls[0]
def __eq__(self, other): """ 2009-12-12 """ if self.chromosome==other.chromosome: if len(self.span_ls)==1: if len(other.span_ls)==1: return self.span_ls[0]==other.span_ls[0] elif len(other.span_ls)>1: return self.span_ls[0]>=other.span_ls[0] and self.span_ls[0]<=other.span_ls[1] # equal if self is within the "other" se...
import os, sys
import os, sys, math
def getCNVDataFromFileInGWA(input_fname_ls, array_id, max_amp=-0.33, min_amp=-0.33, min_size=50, min_no_of_probes=None, report=False): """ 2009-10-31 get deletion (below max_amp) or duplication (above min_amp) from files (output by RunGADA.py) """ sys.stderr.write("Getting CNV calls for array %s, min_size %s, min_no_of...