repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
obulkin/string-dist
stringdist/pystringdist/rdlevenshtein.py
rdlevenshtein_norm
def rdlevenshtein_norm(source, target): """Calculates the normalized restricted Damerau-Levenshtein distance (a.k.a. the normalized optimal string alignment distance) between two string arguments. The result will be a float in the range [0.0, 1.0], with 1.0 signifying the maximum distance between string...
python
def rdlevenshtein_norm(source, target): """Calculates the normalized restricted Damerau-Levenshtein distance (a.k.a. the normalized optimal string alignment distance) between two string arguments. The result will be a float in the range [0.0, 1.0], with 1.0 signifying the maximum distance between string...
[ "def", "rdlevenshtein_norm", "(", "source", ",", "target", ")", ":", "# Compute restricted Damerau-Levenshtein distance using helper function.", "# The max is always just the length of the longer string, so this is used", "# to normalize result before returning it", "distance", "=", "_leve...
Calculates the normalized restricted Damerau-Levenshtein distance (a.k.a. the normalized optimal string alignment distance) between two string arguments. The result will be a float in the range [0.0, 1.0], with 1.0 signifying the maximum distance between strings with these lengths
[ "Calculates", "the", "normalized", "restricted", "Damerau", "-", "Levenshtein", "distance", "(", "a", ".", "k", ".", "a", ".", "the", "normalized", "optimal", "string", "alignment", "distance", ")", "between", "two", "string", "arguments", ".", "The", "result"...
train
https://github.com/obulkin/string-dist/blob/38d04352d617a5d43b06832cc1bf0aee8978559f/stringdist/pystringdist/rdlevenshtein.py#L18-L29
obulkin/string-dist
stringdist/pystringdist/levenshtein_shared.py
_levenshtein_compute
def _levenshtein_compute(source, target, rd_flag): """Computes the Levenshtein (https://en.wikipedia.org/wiki/Levenshtein_distance) and restricted Damerau-Levenshtein (https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) distances between two Unicode strings with given lengths using t...
python
def _levenshtein_compute(source, target, rd_flag): """Computes the Levenshtein (https://en.wikipedia.org/wiki/Levenshtein_distance) and restricted Damerau-Levenshtein (https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) distances between two Unicode strings with given lengths using t...
[ "def", "_levenshtein_compute", "(", "source", ",", "target", ",", "rd_flag", ")", ":", "# Create matrix of correct size (this is s_len + 1 * t_len + 1 so that the", "# empty prefixes \"\" can also be included). The leftmost column represents", "# transforming various source prefixes into an ...
Computes the Levenshtein (https://en.wikipedia.org/wiki/Levenshtein_distance) and restricted Damerau-Levenshtein (https://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance) distances between two Unicode strings with given lengths using the Wagner-Fischer algorithm (https://en.wikipedia....
[ "Computes", "the", "Levenshtein", "(", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Levenshtein_distance", ")", "and", "restricted", "Damerau", "-", "Levenshtein", "(", "https", ":", "//", "en", ".", "wikipedia", ".", "org", ...
train
https://github.com/obulkin/string-dist/blob/38d04352d617a5d43b06832cc1bf0aee8978559f/stringdist/pystringdist/levenshtein_shared.py#L5-L65
mretegan/crispy
setup.py
main
def main(): """The main entry point.""" if sys.version_info < (2, 7): sys.exit('crispy requires at least Python 2.7') elif sys.version_info[0] == 3 and sys.version_info < (3, 4): sys.exit('crispy requires at least Python 3.4') kwargs = dict( name='crispy', version=get_ve...
python
def main(): """The main entry point.""" if sys.version_info < (2, 7): sys.exit('crispy requires at least Python 2.7') elif sys.version_info[0] == 3 and sys.version_info < (3, 4): sys.exit('crispy requires at least Python 3.4') kwargs = dict( name='crispy', version=get_ve...
[ "def", "main", "(", ")", ":", "if", "sys", ".", "version_info", "<", "(", "2", ",", "7", ")", ":", "sys", ".", "exit", "(", "'crispy requires at least Python 2.7'", ")", "elif", "sys", ".", "version_info", "[", "0", "]", "==", "3", "and", "sys", ".",...
The main entry point.
[ "The", "main", "entry", "point", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/setup.py#L68-L145
mretegan/crispy
crispy/gui/quanty.py
QuantySpectra.loadFromDisk
def loadFromDisk(self, calculation): """ Read the spectra from the files generated by Quanty and store them as a list of spectum objects. """ suffixes = { 'Isotropic': 'iso', 'Circular Dichroism (R-L)': 'cd', 'Right Polarized (R)': 'r', ...
python
def loadFromDisk(self, calculation): """ Read the spectra from the files generated by Quanty and store them as a list of spectum objects. """ suffixes = { 'Isotropic': 'iso', 'Circular Dichroism (R-L)': 'cd', 'Right Polarized (R)': 'r', ...
[ "def", "loadFromDisk", "(", "self", ",", "calculation", ")", ":", "suffixes", "=", "{", "'Isotropic'", ":", "'iso'", ",", "'Circular Dichroism (R-L)'", ":", "'cd'", ",", "'Right Polarized (R)'", ":", "'r'", ",", "'Left Polarized (L)'", ":", "'l'", ",", "'Linear ...
Read the spectra from the files generated by Quanty and store them as a list of spectum objects.
[ "Read", "the", "spectra", "from", "the", "files", "generated", "by", "Quanty", "and", "store", "them", "as", "a", "list", "of", "spectum", "objects", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L284-L372
mretegan/crispy
crispy/gui/quanty.py
QuantyDockWidget.populateWidget
def populateWidget(self): """ Populate the widget using data stored in the state object. The order in which the individual widgets are populated follows their arrangment. The models are recreated every time the function is called. This might seem to be an overkill, but i...
python
def populateWidget(self): """ Populate the widget using data stored in the state object. The order in which the individual widgets are populated follows their arrangment. The models are recreated every time the function is called. This might seem to be an overkill, but i...
[ "def", "populateWidget", "(", "self", ")", ":", "self", ".", "elementComboBox", ".", "setItems", "(", "self", ".", "state", ".", "_elements", ",", "self", ".", "state", ".", "element", ")", "self", ".", "chargeComboBox", ".", "setItems", "(", "self", "."...
Populate the widget using data stored in the state object. The order in which the individual widgets are populated follows their arrangment. The models are recreated every time the function is called. This might seem to be an overkill, but in practice it is very fast. Don't try ...
[ "Populate", "the", "widget", "using", "data", "stored", "in", "the", "state", "object", ".", "The", "order", "in", "which", "the", "individual", "widgets", "are", "populated", "follows", "their", "arrangment", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L754-L899
mretegan/crispy
crispy/gui/quanty.py
QuantyDockWidget.updateResultsView
def updateResultsView(self, index): """ Update the selection to contain only the result specified by the index. This should be the last index of the model. Finally updade the context menu. The selectionChanged signal is used to trigger the update of the Quanty dock widge...
python
def updateResultsView(self, index): """ Update the selection to contain only the result specified by the index. This should be the last index of the model. Finally updade the context menu. The selectionChanged signal is used to trigger the update of the Quanty dock widge...
[ "def", "updateResultsView", "(", "self", ",", "index", ")", ":", "flags", "=", "(", "QItemSelectionModel", ".", "Clear", "|", "QItemSelectionModel", ".", "Rows", "|", "QItemSelectionModel", ".", "Select", ")", "self", ".", "resultsView", ".", "selectionModel", ...
Update the selection to contain only the result specified by the index. This should be the last index of the model. Finally updade the context menu. The selectionChanged signal is used to trigger the update of the Quanty dock widget and result details dialog. :param index: Inde...
[ "Update", "the", "selection", "to", "contain", "only", "the", "result", "specified", "by", "the", "index", ".", "This", "should", "be", "the", "last", "index", "of", "the", "model", ".", "Finally", "updade", "the", "context", "menu", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L1774-L1791
mretegan/crispy
crispy/gui/quanty.py
QuantyDockWidget.updatePlotWidget
def updatePlotWidget(self): """Updating the plotting widget should not require any information about the current state of the widget.""" pw = self.getPlotWidget() pw.reset() results = self.resultsModel.getCheckedItems() for result in results: if isinstance(r...
python
def updatePlotWidget(self): """Updating the plotting widget should not require any information about the current state of the widget.""" pw = self.getPlotWidget() pw.reset() results = self.resultsModel.getCheckedItems() for result in results: if isinstance(r...
[ "def", "updatePlotWidget", "(", "self", ")", ":", "pw", "=", "self", ".", "getPlotWidget", "(", ")", "pw", ".", "reset", "(", ")", "results", "=", "self", ".", "resultsModel", ".", "getCheckedItems", "(", ")", "for", "result", "in", "results", ":", "if...
Updating the plotting widget should not require any information about the current state of the widget.
[ "Updating", "the", "plotting", "widget", "should", "not", "require", "any", "information", "about", "the", "current", "state", "of", "the", "widget", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/quanty.py#L1832-L1854
mretegan/crispy
crispy/gui/models.py
HamiltonianItem.row
def row(self): """Return the row of the child.""" if self.parent is not None: children = self.parent.getChildren() # The index method of the list object. return children.index(self) else: return 0
python
def row(self): """Return the row of the child.""" if self.parent is not None: children = self.parent.getChildren() # The index method of the list object. return children.index(self) else: return 0
[ "def", "row", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "not", "None", ":", "children", "=", "self", ".", "parent", ".", "getChildren", "(", ")", "# The index method of the list object.", "return", "children", ".", "index", "(", "self", ")"...
Return the row of the child.
[ "Return", "the", "row", "of", "the", "child", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L254-L261
mretegan/crispy
crispy/gui/models.py
HamiltonianModel.index
def index(self, row, column, parent=QModelIndex()): """Return the index of the item in the model specified by the given row, column, and parent index. """ if parent is not None and not parent.isValid(): parentItem = self.rootItem else: parentItem = self.it...
python
def index(self, row, column, parent=QModelIndex()): """Return the index of the item in the model specified by the given row, column, and parent index. """ if parent is not None and not parent.isValid(): parentItem = self.rootItem else: parentItem = self.it...
[ "def", "index", "(", "self", ",", "row", ",", "column", ",", "parent", "=", "QModelIndex", "(", ")", ")", ":", "if", "parent", "is", "not", "None", "and", "not", "parent", ".", "isValid", "(", ")", ":", "parentItem", "=", "self", ".", "rootItem", "...
Return the index of the item in the model specified by the given row, column, and parent index.
[ "Return", "the", "index", "of", "the", "item", "in", "the", "model", "specified", "by", "the", "given", "row", "column", "and", "parent", "index", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L307-L323
mretegan/crispy
crispy/gui/models.py
HamiltonianModel.parent
def parent(self, index): """Return the index of the parent for a given index of the child. Unfortunately, the name of the method has to be parent, even though a more verbose name like parentIndex, would avoid confusion about what parent actually is - an index or an item. """ ...
python
def parent(self, index): """Return the index of the parent for a given index of the child. Unfortunately, the name of the method has to be parent, even though a more verbose name like parentIndex, would avoid confusion about what parent actually is - an index or an item. """ ...
[ "def", "parent", "(", "self", ",", "index", ")", ":", "childItem", "=", "self", ".", "item", "(", "index", ")", "parentItem", "=", "childItem", ".", "parent", "if", "parentItem", "==", "self", ".", "rootItem", ":", "parentIndex", "=", "QModelIndex", "(",...
Return the index of the parent for a given index of the child. Unfortunately, the name of the method has to be parent, even though a more verbose name like parentIndex, would avoid confusion about what parent actually is - an index or an item.
[ "Return", "the", "index", "of", "the", "parent", "for", "a", "given", "index", "of", "the", "child", ".", "Unfortunately", "the", "name", "of", "the", "method", "has", "to", "be", "parent", "even", "though", "a", "more", "verbose", "name", "like", "paren...
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L325-L339
mretegan/crispy
crispy/gui/models.py
HamiltonianModel.rowCount
def rowCount(self, parentIndex): """Return the number of rows under the given parent. When the parentIndex is valid, rowCount() returns the number of children of the parent. For this it uses item() method to extract the parentItem from the parentIndex, and calls the childCount() of ...
python
def rowCount(self, parentIndex): """Return the number of rows under the given parent. When the parentIndex is valid, rowCount() returns the number of children of the parent. For this it uses item() method to extract the parentItem from the parentIndex, and calls the childCount() of ...
[ "def", "rowCount", "(", "self", ",", "parentIndex", ")", ":", "if", "parentIndex", ".", "column", "(", ")", ">", "0", ":", "return", "0", "if", "not", "parentIndex", ".", "isValid", "(", ")", ":", "parentItem", "=", "self", ".", "rootItem", "else", "...
Return the number of rows under the given parent. When the parentIndex is valid, rowCount() returns the number of children of the parent. For this it uses item() method to extract the parentItem from the parentIndex, and calls the childCount() of the item to get number of children.
[ "Return", "the", "number", "of", "rows", "under", "the", "given", "parent", ".", "When", "the", "parentIndex", "is", "valid", "rowCount", "()", "returns", "the", "number", "of", "children", "of", "the", "parent", ".", "For", "this", "it", "uses", "item", ...
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L358-L373
mretegan/crispy
crispy/gui/models.py
HamiltonianModel.data
def data(self, index, role): """Return role specific data for the item referred by index.column().""" if not index.isValid(): return item = self.item(index) column = index.column() value = item.getItemData(column) if role == Qt.DisplayRole: ...
python
def data(self, index, role): """Return role specific data for the item referred by index.column().""" if not index.isValid(): return item = self.item(index) column = index.column() value = item.getItemData(column) if role == Qt.DisplayRole: ...
[ "def", "data", "(", "self", ",", "index", ",", "role", ")", ":", "if", "not", "index", ".", "isValid", "(", ")", ":", "return", "item", "=", "self", ".", "item", "(", "index", ")", "column", "=", "index", ".", "column", "(", ")", "value", "=", ...
Return role specific data for the item referred by index.column().
[ "Return", "role", "specific", "data", "for", "the", "item", "referred", "by", "index", ".", "column", "()", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L382-L418
mretegan/crispy
crispy/gui/models.py
HamiltonianModel.setData
def setData(self, index, value, role): """Set the role data for the item at index to value.""" if not index.isValid(): return False item = self.item(index) column = index.column() if role == Qt.EditRole: items = list() items.append(item) ...
python
def setData(self, index, value, role): """Set the role data for the item at index to value.""" if not index.isValid(): return False item = self.item(index) column = index.column() if role == Qt.EditRole: items = list() items.append(item) ...
[ "def", "setData", "(", "self", ",", "index", ",", "value", ",", "role", ")", ":", "if", "not", "index", ".", "isValid", "(", ")", ":", "return", "False", "item", "=", "self", ".", "item", "(", "index", ")", "column", "=", "index", ".", "column", ...
Set the role data for the item at index to value.
[ "Set", "the", "role", "data", "for", "the", "item", "at", "index", "to", "value", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L420-L459
mretegan/crispy
crispy/gui/models.py
HamiltonianModel.flags
def flags(self, index): """Return the active flags for the given index. Add editable flag to items other than the first column. """ activeFlags = (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable) item = self.item(index) column = ind...
python
def flags(self, index): """Return the active flags for the given index. Add editable flag to items other than the first column. """ activeFlags = (Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsUserCheckable) item = self.item(index) column = ind...
[ "def", "flags", "(", "self", ",", "index", ")", ":", "activeFlags", "=", "(", "Qt", ".", "ItemIsEnabled", "|", "Qt", ".", "ItemIsSelectable", "|", "Qt", ".", "ItemIsUserCheckable", ")", "item", "=", "self", ".", "item", "(", "index", ")", "column", "="...
Return the active flags for the given index. Add editable flag to items other than the first column.
[ "Return", "the", "active", "flags", "for", "the", "given", "index", ".", "Add", "editable", "flag", "to", "items", "other", "than", "the", "first", "column", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L464-L477
mretegan/crispy
crispy/gui/models.py
HamiltonianModel._getModelData
def _getModelData(self, modelData, parentItem=None): """Return the data contained in the model.""" if parentItem is None: parentItem = self.rootItem for item in parentItem.getChildren(): key = item.getItemData(0) if item.childCount(): modelDat...
python
def _getModelData(self, modelData, parentItem=None): """Return the data contained in the model.""" if parentItem is None: parentItem = self.rootItem for item in parentItem.getChildren(): key = item.getItemData(0) if item.childCount(): modelDat...
[ "def", "_getModelData", "(", "self", ",", "modelData", ",", "parentItem", "=", "None", ")", ":", "if", "parentItem", "is", "None", ":", "parentItem", "=", "self", ".", "rootItem", "for", "item", "in", "parentItem", ".", "getChildren", "(", ")", ":", "key...
Return the data contained in the model.
[ "Return", "the", "data", "contained", "in", "the", "model", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L533-L547
mretegan/crispy
crispy/gui/models.py
HamiltonianModel.getNodesCheckState
def getNodesCheckState(self, parentItem=None): """Return the check state (disabled, tristate, enable) of all items belonging to a parent. """ if parentItem is None: parentItem = self.rootItem checkStates = odict() children = parentItem.getChildren() ...
python
def getNodesCheckState(self, parentItem=None): """Return the check state (disabled, tristate, enable) of all items belonging to a parent. """ if parentItem is None: parentItem = self.rootItem checkStates = odict() children = parentItem.getChildren() ...
[ "def", "getNodesCheckState", "(", "self", ",", "parentItem", "=", "None", ")", ":", "if", "parentItem", "is", "None", ":", "parentItem", "=", "self", ".", "rootItem", "checkStates", "=", "odict", "(", ")", "children", "=", "parentItem", ".", "getChildren", ...
Return the check state (disabled, tristate, enable) of all items belonging to a parent.
[ "Return", "the", "check", "state", "(", "disabled", "tristate", "enable", ")", "of", "all", "items", "belonging", "to", "a", "parent", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/models.py#L567-L580
mretegan/crispy
crispy/version.py
calc_hexversion
def calc_hexversion(major=0, minor=0, micro=0, releaselevel='dev', serial=0): """Calculate the hexadecimal version number from the tuple version_info: :param major: integer :param minor: integer :param micro: integer :param relev: integer or string :param serial: integer :return: integerm a...
python
def calc_hexversion(major=0, minor=0, micro=0, releaselevel='dev', serial=0): """Calculate the hexadecimal version number from the tuple version_info: :param major: integer :param minor: integer :param micro: integer :param relev: integer or string :param serial: integer :return: integerm a...
[ "def", "calc_hexversion", "(", "major", "=", "0", ",", "minor", "=", "0", ",", "micro", "=", "0", ",", "releaselevel", "=", "'dev'", ",", "serial", "=", "0", ")", ":", "try", ":", "releaselevel", "=", "int", "(", "releaselevel", ")", "except", "Value...
Calculate the hexadecimal version number from the tuple version_info: :param major: integer :param minor: integer :param micro: integer :param relev: integer or string :param serial: integer :return: integerm always increasing with revision numbers
[ "Calculate", "the", "hexadecimal", "version", "number", "from", "the", "tuple", "version_info", ":" ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/version.py#L89-L109
mretegan/crispy
crispy/gui/plot.py
MainPlotWidget._contextMenu
def _contextMenu(self, pos): """Handle plot area customContextMenuRequested signal. :param QPoint pos: Mouse position relative to plot area """ # Create the context menu. menu = QMenu(self) menu.addAction(self._zoomBackAction) # Displaying the context menu at th...
python
def _contextMenu(self, pos): """Handle plot area customContextMenuRequested signal. :param QPoint pos: Mouse position relative to plot area """ # Create the context menu. menu = QMenu(self) menu.addAction(self._zoomBackAction) # Displaying the context menu at th...
[ "def", "_contextMenu", "(", "self", ",", "pos", ")", ":", "# Create the context menu.", "menu", "=", "QMenu", "(", "self", ")", "menu", ".", "addAction", "(", "self", ".", "_zoomBackAction", ")", "# Displaying the context menu at the mouse position requires", "# a glo...
Handle plot area customContextMenuRequested signal. :param QPoint pos: Mouse position relative to plot area
[ "Handle", "plot", "area", "customContextMenuRequested", "signal", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/gui/plot.py#L247-L262
mretegan/crispy
crispy/utils/broaden.py
convolve_fft
def convolve_fft(array, kernel): """ Convolve an array with a kernel using FFT. Implemntation based on the convolve_fft function from astropy. https://github.com/astropy/astropy/blob/master/astropy/convolution/convolve.py """ array = np.asarray(array, dtype=np.complex) kernel = np.asarray(...
python
def convolve_fft(array, kernel): """ Convolve an array with a kernel using FFT. Implemntation based on the convolve_fft function from astropy. https://github.com/astropy/astropy/blob/master/astropy/convolution/convolve.py """ array = np.asarray(array, dtype=np.complex) kernel = np.asarray(...
[ "def", "convolve_fft", "(", "array", ",", "kernel", ")", ":", "array", "=", "np", ".", "asarray", "(", "array", ",", "dtype", "=", "np", ".", "complex", ")", "kernel", "=", "np", ".", "asarray", "(", "kernel", ",", "dtype", "=", "np", ".", "complex...
Convolve an array with a kernel using FFT. Implemntation based on the convolve_fft function from astropy. https://github.com/astropy/astropy/blob/master/astropy/convolution/convolve.py
[ "Convolve", "an", "array", "with", "a", "kernel", "using", "FFT", ".", "Implemntation", "based", "on", "the", "convolve_fft", "function", "from", "astropy", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/utils/broaden.py#L65-L114
mretegan/crispy
crispy/modules/orca/parser.py
Tensor.diagonalize
def diagonalize(self): '''Diagonalize the tensor.''' self.eigvals, self.eigvecs = np.linalg.eig( (self.tensor.transpose() + self.tensor) / 2.0) self.eigvals = np.diag(np.dot( np.dot(self.eigvecs.transpose(), self.tensor), self.eigvecs))
python
def diagonalize(self): '''Diagonalize the tensor.''' self.eigvals, self.eigvecs = np.linalg.eig( (self.tensor.transpose() + self.tensor) / 2.0) self.eigvals = np.diag(np.dot( np.dot(self.eigvecs.transpose(), self.tensor), self.eigvecs))
[ "def", "diagonalize", "(", "self", ")", ":", "self", ".", "eigvals", ",", "self", ".", "eigvecs", "=", "np", ".", "linalg", ".", "eig", "(", "(", "self", ".", "tensor", ".", "transpose", "(", ")", "+", "self", ".", "tensor", ")", "/", "2.0", ")",...
Diagonalize the tensor.
[ "Diagonalize", "the", "tensor", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L61-L66
mretegan/crispy
crispy/modules/orca/parser.py
Tensor.euler_angles_and_eigenframes
def euler_angles_and_eigenframes(self): '''Calculate the Euler angles only if the rotation matrix (eigenframe) has positive determinant.''' signs = np.array([[1, 1, 1], [-1, 1, 1], [1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, 1, -1], [1, -1, -1...
python
def euler_angles_and_eigenframes(self): '''Calculate the Euler angles only if the rotation matrix (eigenframe) has positive determinant.''' signs = np.array([[1, 1, 1], [-1, 1, 1], [1, -1, 1], [1, 1, -1], [-1, -1, 1], [-1, 1, -1], [1, -1, -1...
[ "def", "euler_angles_and_eigenframes", "(", "self", ")", ":", "signs", "=", "np", ".", "array", "(", "[", "[", "1", ",", "1", ",", "1", "]", ",", "[", "-", "1", ",", "1", ",", "1", "]", ",", "[", "1", ",", "-", "1", ",", "1", "]", ",", "[...
Calculate the Euler angles only if the rotation matrix (eigenframe) has positive determinant.
[ "Calculate", "the", "Euler", "angles", "only", "if", "the", "rotation", "matrix", "(", "eigenframe", ")", "has", "positive", "determinant", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L75-L92
mretegan/crispy
crispy/modules/orca/parser.py
OutputData._skip_lines
def _skip_lines(self, n): '''Skip a number of lines from the output.''' for i in range(n): self.line = next(self.output) return self.line
python
def _skip_lines(self, n): '''Skip a number of lines from the output.''' for i in range(n): self.line = next(self.output) return self.line
[ "def", "_skip_lines", "(", "self", ",", "n", ")", ":", "for", "i", "in", "range", "(", "n", ")", ":", "self", ".", "line", "=", "next", "(", "self", ".", "output", ")", "return", "self", ".", "line" ]
Skip a number of lines from the output.
[ "Skip", "a", "number", "of", "lines", "from", "the", "output", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L151-L155
mretegan/crispy
crispy/modules/orca/parser.py
OutputData._parse_tensor
def _parse_tensor(self, indices=False): '''Parse a tensor.''' if indices: self.line = self._skip_lines(1) tensor = np.zeros((3, 3)) for i in range(3): tokens = self.line.split() if indices: tensor[i][0] = float(tokens[1]) ...
python
def _parse_tensor(self, indices=False): '''Parse a tensor.''' if indices: self.line = self._skip_lines(1) tensor = np.zeros((3, 3)) for i in range(3): tokens = self.line.split() if indices: tensor[i][0] = float(tokens[1]) ...
[ "def", "_parse_tensor", "(", "self", ",", "indices", "=", "False", ")", ":", "if", "indices", ":", "self", ".", "line", "=", "self", ".", "_skip_lines", "(", "1", ")", "tensor", "=", "np", ".", "zeros", "(", "(", "3", ",", "3", ")", ")", "for", ...
Parse a tensor.
[ "Parse", "a", "tensor", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L157-L174
mretegan/crispy
crispy/modules/orca/parser.py
OutputData.parse
def parse(self): '''Iterate over the lines and extract the required data.''' for self.line in self.output: # Parse general data: charge, multiplicity, coordinates, etc. self.index = 0 if self.line[1:13] == 'Total Charge': tokens = self.line.split() ...
python
def parse(self): '''Iterate over the lines and extract the required data.''' for self.line in self.output: # Parse general data: charge, multiplicity, coordinates, etc. self.index = 0 if self.line[1:13] == 'Total Charge': tokens = self.line.split() ...
[ "def", "parse", "(", "self", ")", ":", "for", "self", ".", "line", "in", "self", ".", "output", ":", "# Parse general data: charge, multiplicity, coordinates, etc.", "self", ".", "index", "=", "0", "if", "self", ".", "line", "[", "1", ":", "13", "]", "==",...
Iterate over the lines and extract the required data.
[ "Iterate", "over", "the", "lines", "and", "extract", "the", "required", "data", "." ]
train
https://github.com/mretegan/crispy/blob/7e241ac1a48d34ca769f3a6183c430360b5f6725/crispy/modules/orca/parser.py#L185-L275
xeBuz/Flask-Validator
flask_validator/validator.py
FlaskValidator.__validate
def __validate(self, target, value, oldvalue, initiator): """ Method executed when the event 'set' is triggered. :param target: Object triggered :param value: New value :param oldvalue: Previous value :param initiator: Column modified :return: :raise ValidateError: ...
python
def __validate(self, target, value, oldvalue, initiator): """ Method executed when the event 'set' is triggered. :param target: Object triggered :param value: New value :param oldvalue: Previous value :param initiator: Column modified :return: :raise ValidateError: ...
[ "def", "__validate", "(", "self", ",", "target", ",", "value", ",", "oldvalue", ",", "initiator", ")", ":", "if", "value", "==", "oldvalue", ":", "return", "value", "if", "self", ".", "allow_null", "and", "value", "is", "None", ":", "return", "value", ...
Method executed when the event 'set' is triggered. :param target: Object triggered :param value: New value :param oldvalue: Previous value :param initiator: Column modified :return: :raise ValidateError:
[ "Method", "executed", "when", "the", "event", "set", "is", "triggered", "." ]
train
https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L35-L62
xeBuz/Flask-Validator
flask_validator/validator.py
FlaskValidator.__create_event
def __create_event(self): """ Create an SQLAlchemy event listening the 'set' in a particular column. :rtype : object """ if not event.contains(self.field, 'set', self.__validate): event.listen(self.field, 'set', self.__validate, retval=True)
python
def __create_event(self): """ Create an SQLAlchemy event listening the 'set' in a particular column. :rtype : object """ if not event.contains(self.field, 'set', self.__validate): event.listen(self.field, 'set', self.__validate, retval=True)
[ "def", "__create_event", "(", "self", ")", ":", "if", "not", "event", ".", "contains", "(", "self", ".", "field", ",", "'set'", ",", "self", ".", "__validate", ")", ":", "event", ".", "listen", "(", "self", ".", "field", ",", "'set'", ",", "self", ...
Create an SQLAlchemy event listening the 'set' in a particular column. :rtype : object
[ "Create", "an", "SQLAlchemy", "event", "listening", "the", "set", "in", "a", "particular", "column", "." ]
train
https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L64-L70
xeBuz/Flask-Validator
flask_validator/validator.py
FlaskValidator.stop
def stop(self): """ Remove the listener to stop the validation """ if event.contains(self.field, 'set', self.__validate): event.remove(self.field, 'set', self.__validate)
python
def stop(self): """ Remove the listener to stop the validation """ if event.contains(self.field, 'set', self.__validate): event.remove(self.field, 'set', self.__validate)
[ "def", "stop", "(", "self", ")", ":", "if", "event", ".", "contains", "(", "self", ".", "field", ",", "'set'", ",", "self", ".", "__validate", ")", ":", "event", ".", "remove", "(", "self", ".", "field", ",", "'set'", ",", "self", ".", "__validate"...
Remove the listener to stop the validation
[ "Remove", "the", "listener", "to", "stop", "the", "validation" ]
train
https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L80-L84
xeBuz/Flask-Validator
flask_validator/validator.py
FlaskValidator.start
def start(self): """ Restart the listener """ if not event.contains(self.field, 'set', self.__validate): self.__create_event()
python
def start(self): """ Restart the listener """ if not event.contains(self.field, 'set', self.__validate): self.__create_event()
[ "def", "start", "(", "self", ")", ":", "if", "not", "event", ".", "contains", "(", "self", ".", "field", ",", "'set'", ",", "self", ".", "__validate", ")", ":", "self", ".", "__create_event", "(", ")" ]
Restart the listener
[ "Restart", "the", "listener" ]
train
https://github.com/xeBuz/Flask-Validator/blob/ef3dd0a24300c88cb728e6dc1a221e7e7127e1f9/flask_validator/validator.py#L86-L90
doanguyen/lasotuvi
lasotuvi/DiaBan.py
diaBan.nhapDaiHan
def nhapDaiHan(self, cucSo, gioiTinh): """Nhap dai han Args: cucSo (TYPE): Description gioiTinh (TYPE): Description Returns: TYPE: Description """ for cung in self.thapNhiCung: khoangCach = khoangCachCung(cung.cungSo, self.cungMen...
python
def nhapDaiHan(self, cucSo, gioiTinh): """Nhap dai han Args: cucSo (TYPE): Description gioiTinh (TYPE): Description Returns: TYPE: Description """ for cung in self.thapNhiCung: khoangCach = khoangCachCung(cung.cungSo, self.cungMen...
[ "def", "nhapDaiHan", "(", "self", ",", "cucSo", ",", "gioiTinh", ")", ":", "for", "cung", "in", "self", ".", "thapNhiCung", ":", "khoangCach", "=", "khoangCachCung", "(", "cung", ".", "cungSo", ",", "self", ".", "cungMenh", ",", "gioiTinh", ")", "cung", ...
Nhap dai han Args: cucSo (TYPE): Description gioiTinh (TYPE): Description Returns: TYPE: Description
[ "Nhap", "dai", "han" ]
train
https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/DiaBan.py#L153-L166
tansey/gfl
pygfl/easy.py
solve_gfl
def solve_gfl(data, edges=None, weights=None, minlam=0.2, maxlam=1000.0, numlam=30, alpha=0.2, inflate=2., converge=1e-6, maxsteps=1000000, lam=None, verbose=0, missing_val=None, full_path=False, loss='normal'): '''A very easy-to-use version of G...
python
def solve_gfl(data, edges=None, weights=None, minlam=0.2, maxlam=1000.0, numlam=30, alpha=0.2, inflate=2., converge=1e-6, maxsteps=1000000, lam=None, verbose=0, missing_val=None, full_path=False, loss='normal'): '''A very easy-to-use version of G...
[ "def", "solve_gfl", "(", "data", ",", "edges", "=", "None", ",", "weights", "=", "None", ",", "minlam", "=", "0.2", ",", "maxlam", "=", "1000.0", ",", "numlam", "=", "30", ",", "alpha", "=", "0.2", ",", "inflate", "=", "2.", ",", "converge", "=", ...
A very easy-to-use version of GFL solver that just requires the data and the edges.
[ "A", "very", "easy", "-", "to", "-", "use", "version", "of", "GFL", "solver", "that", "just", "requires", "the", "data", "and", "the", "edges", "." ]
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/easy.py#L27-L113
doanguyen/lasotuvi
lasotuvi/AmDuong.py
ngayThangNam
def ngayThangNam(nn, tt, nnnn, duongLich=True, timeZone=7): """Summary Args: nn (TYPE): ngay tt (TYPE): thang nnnn (TYPE): nam duongLich (bool, optional): bool timeZone (int, optional): +7 Vietnam Returns: TYPE: Description Raises: Exception: De...
python
def ngayThangNam(nn, tt, nnnn, duongLich=True, timeZone=7): """Summary Args: nn (TYPE): ngay tt (TYPE): thang nnnn (TYPE): nam duongLich (bool, optional): bool timeZone (int, optional): +7 Vietnam Returns: TYPE: Description Raises: Exception: De...
[ "def", "ngayThangNam", "(", "nn", ",", "tt", ",", "nnnn", ",", "duongLich", "=", "True", ",", "timeZone", "=", "7", ")", ":", "thangNhuan", "=", "0", "# if nnnn > 1000 and nnnn < 3000 and nn > 0 and \\", "if", "nn", ">", "0", "and", "nn", "<", "32", "and",...
Summary Args: nn (TYPE): ngay tt (TYPE): thang nnnn (TYPE): nam duongLich (bool, optional): bool timeZone (int, optional): +7 Vietnam Returns: TYPE: Description Raises: Exception: Description
[ "Summary" ]
train
https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L218-L242
doanguyen/lasotuvi
lasotuvi/AmDuong.py
canChiNgay
def canChiNgay(nn, tt, nnnn, duongLich=True, timeZone=7, thangNhuan=False): """Summary Args: nn (int): ngày tt (int): tháng nnnn (int): năm duongLich (bool, optional): True nếu là dương lịch, False âm lịch timeZone (int, optional): Múi giờ thangNhuan (bool, optio...
python
def canChiNgay(nn, tt, nnnn, duongLich=True, timeZone=7, thangNhuan=False): """Summary Args: nn (int): ngày tt (int): tháng nnnn (int): năm duongLich (bool, optional): True nếu là dương lịch, False âm lịch timeZone (int, optional): Múi giờ thangNhuan (bool, optio...
[ "def", "canChiNgay", "(", "nn", ",", "tt", ",", "nnnn", ",", "duongLich", "=", "True", ",", "timeZone", "=", "7", ",", "thangNhuan", "=", "False", ")", ":", "if", "duongLich", "is", "False", ":", "[", "nn", ",", "tt", ",", "nnnn", "]", "=", "L2S"...
Summary Args: nn (int): ngày tt (int): tháng nnnn (int): năm duongLich (bool, optional): True nếu là dương lịch, False âm lịch timeZone (int, optional): Múi giờ thangNhuan (bool, optional): Có phải là tháng nhuận không? Returns: TYPE: Description
[ "Summary" ]
train
https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L245-L265
doanguyen/lasotuvi
lasotuvi/AmDuong.py
ngayThangNamCanChi
def ngayThangNamCanChi(nn, tt, nnnn, duongLich=True, timeZone=7): """chuyển đổi năm, tháng âm/dương lịch sang Can, Chi trong tiếng Việt. Không tính đến can ngày vì phải chuyển đổi qua lịch Julius. Hàm tìm can ngày là hàm canChiNgay(nn, tt, nnnn, duongLich=True,\ timeZone...
python
def ngayThangNamCanChi(nn, tt, nnnn, duongLich=True, timeZone=7): """chuyển đổi năm, tháng âm/dương lịch sang Can, Chi trong tiếng Việt. Không tính đến can ngày vì phải chuyển đổi qua lịch Julius. Hàm tìm can ngày là hàm canChiNgay(nn, tt, nnnn, duongLich=True,\ timeZone...
[ "def", "ngayThangNamCanChi", "(", "nn", ",", "tt", ",", "nnnn", ",", "duongLich", "=", "True", ",", "timeZone", "=", "7", ")", ":", "if", "duongLich", "is", "True", ":", "[", "nn", ",", "tt", ",", "nnnn", ",", "thangNhuan", "]", "=", "ngayThangNam", ...
chuyển đổi năm, tháng âm/dương lịch sang Can, Chi trong tiếng Việt. Không tính đến can ngày vì phải chuyển đổi qua lịch Julius. Hàm tìm can ngày là hàm canChiNgay(nn, tt, nnnn, duongLich=True,\ timeZone=7, thangNhuan=False) Args: nn (int): Ngày tt (int):...
[ "chuyển", "đổi", "năm", "tháng", "âm", "/", "dương", "lịch", "sang", "Can", "Chi", "trong", "tiếng", "Việt", ".", "Không", "tính", "đến", "can", "ngày", "vì", "phải", "chuyển", "đổi", "qua", "lịch", "Julius", "." ]
train
https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L281-L305
doanguyen/lasotuvi
lasotuvi/AmDuong.py
nguHanh
def nguHanh(tenHanh): """ Args: tenHanh (string): Tên Hành trong ngũ hành, Kim hoặc K, Moc hoặc M, Thuy hoặc T, Hoa hoặc H, Tho hoặc O Returns: Dictionary: ID của Hành, tên đầy đủ của Hành, số Cục của Hành Raises: Exception: Description """ if tenHanh in ["Kim",...
python
def nguHanh(tenHanh): """ Args: tenHanh (string): Tên Hành trong ngũ hành, Kim hoặc K, Moc hoặc M, Thuy hoặc T, Hoa hoặc H, Tho hoặc O Returns: Dictionary: ID của Hành, tên đầy đủ của Hành, số Cục của Hành Raises: Exception: Description """ if tenHanh in ["Kim",...
[ "def", "nguHanh", "(", "tenHanh", ")", ":", "if", "tenHanh", "in", "[", "\"Kim\"", ",", "\"K\"", "]", ":", "return", "{", "\"id\"", ":", "1", ",", "\"tenHanh\"", ":", "\"Kim\"", ",", "\"cuc\"", ":", "4", ",", "\"tenCuc\"", ":", "\"Kim tứ Cục\",", "", ...
Args: tenHanh (string): Tên Hành trong ngũ hành, Kim hoặc K, Moc hoặc M, Thuy hoặc T, Hoa hoặc H, Tho hoặc O Returns: Dictionary: ID của Hành, tên đầy đủ của Hành, số Cục của Hành Raises: Exception: Description
[ "Args", ":", "tenHanh", "(", "string", ")", ":", "Tên", "Hành", "trong", "ngũ", "hành", "Kim", "hoặc", "K", "Moc", "hoặc", "M", "Thuy", "hoặc", "T", "Hoa", "hoặc", "H", "Tho", "hoặc", "O" ]
train
https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L308-L338
doanguyen/lasotuvi
lasotuvi/AmDuong.py
nguHanhNapAm
def nguHanhNapAm(diaChi, thienCan, xuatBanMenh=False): """Sử dụng Ngũ Hành nạp âm để tính Hành của năm. Args: diaChi (integer): Số thứ tự của địa chi (Tý=1, Sửu=2,...) thienCan (integer): Số thứ tự của thiên can (Giáp=1, Ất=2,...) Returns: Trả về chữ viết tắt Hành của năm (K, T, H,...
python
def nguHanhNapAm(diaChi, thienCan, xuatBanMenh=False): """Sử dụng Ngũ Hành nạp âm để tính Hành của năm. Args: diaChi (integer): Số thứ tự của địa chi (Tý=1, Sửu=2,...) thienCan (integer): Số thứ tự của thiên can (Giáp=1, Ất=2,...) Returns: Trả về chữ viết tắt Hành của năm (K, T, H,...
[ "def", "nguHanhNapAm", "(", "diaChi", ",", "thienCan", ",", "xuatBanMenh", "=", "False", ")", ":", "banMenh", "=", "{", "\"K1\"", ":", "\"HẢI TRUNG KIM\",", "", "\"T1\"", ":", "\"GIÁNG HẠ THỦY\",", "", "\"H1\"", ":", "\"TÍCH LỊCH HỎA\",", "", "\"O1\"", ":", ...
Sử dụng Ngũ Hành nạp âm để tính Hành của năm. Args: diaChi (integer): Số thứ tự của địa chi (Tý=1, Sửu=2,...) thienCan (integer): Số thứ tự của thiên can (Giáp=1, Ất=2,...) Returns: Trả về chữ viết tắt Hành của năm (K, T, H, O, M)
[ "Sử", "dụng", "Ngũ", "Hành", "nạp", "âm", "để", "tính", "Hành", "của", "năm", "." ]
train
https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L361-L425
doanguyen/lasotuvi
lasotuvi/AmDuong.py
timTuVi
def timTuVi(cuc, ngaySinhAmLich): """Tìm vị trí của sao Tử vi Args: cuc (TYPE): Description ngaySinhAmLich (TYPE): Description Returns: TYPE: Description Raises: Exception: Description """ cungDan = 3 # Vị trí cung Dần ban đầu là 3 cucBanDau = cuc if c...
python
def timTuVi(cuc, ngaySinhAmLich): """Tìm vị trí của sao Tử vi Args: cuc (TYPE): Description ngaySinhAmLich (TYPE): Description Returns: TYPE: Description Raises: Exception: Description """ cungDan = 3 # Vị trí cung Dần ban đầu là 3 cucBanDau = cuc if c...
[ "def", "timTuVi", "(", "cuc", ",", "ngaySinhAmLich", ")", ":", "cungDan", "=", "3", "# Vị trí cung Dần ban đầu là 3", "cucBanDau", "=", "cuc", "if", "cuc", "not", "in", "[", "2", ",", "3", ",", "4", ",", "5", ",", "6", "]", ":", "# Tránh trường hợp infin...
Tìm vị trí của sao Tử vi Args: cuc (TYPE): Description ngaySinhAmLich (TYPE): Description Returns: TYPE: Description Raises: Exception: Description
[ "Tìm", "vị", "trí", "của", "sao", "Tử", "vi" ]
train
https://github.com/doanguyen/lasotuvi/blob/98383a3056f0a0633d6937d364c37eb788661c0d/lasotuvi/AmDuong.py#L452-L475
zsethna/OLGA
olga/utils.py
nt2aa
def nt2aa(ntseq): """Translate a nucleotide sequence into an amino acid sequence. Parameters ---------- ntseq : str Nucleotide sequence composed of A, C, G, or T (uppercase or lowercase) Returns ------- aaseq : str Amino acid sequence Example -------- >>> n...
python
def nt2aa(ntseq): """Translate a nucleotide sequence into an amino acid sequence. Parameters ---------- ntseq : str Nucleotide sequence composed of A, C, G, or T (uppercase or lowercase) Returns ------- aaseq : str Amino acid sequence Example -------- >>> n...
[ "def", "nt2aa", "(", "ntseq", ")", ":", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",", "'T'", ":", "3", ",", "'a'", ":", "0", ",", "'c'", ":", "1", ",", "'g'", ":", "2", ",", "'t'", ":", "3", "}", ...
Translate a nucleotide sequence into an amino acid sequence. Parameters ---------- ntseq : str Nucleotide sequence composed of A, C, G, or T (uppercase or lowercase) Returns ------- aaseq : str Amino acid sequence Example -------- >>> nt2aa('TGTGCCTGGAGTGTAGCTC...
[ "Translate", "a", "nucleotide", "sequence", "into", "an", "amino", "acid", "sequence", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L31-L53
zsethna/OLGA
olga/utils.py
nt2codon_rep
def nt2codon_rep(ntseq): """Represent nucleotide sequence by sequence of codon symbols. 'Translates' the nucleotide sequence into a symbolic representation of 'amino acids' where each codon gets its own unique character symbol. These characters should be reserved only for representing the 64 individua...
python
def nt2codon_rep(ntseq): """Represent nucleotide sequence by sequence of codon symbols. 'Translates' the nucleotide sequence into a symbolic representation of 'amino acids' where each codon gets its own unique character symbol. These characters should be reserved only for representing the 64 individua...
[ "def", "nt2codon_rep", "(", "ntseq", ")", ":", "#", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",", "'T'", ":", "3", ",", "'a'", ":", "0", ",", "'c'", ":", "1", ",", "'g'", ":", "2", ",", "'t'", ":", ...
Represent nucleotide sequence by sequence of codon symbols. 'Translates' the nucleotide sequence into a symbolic representation of 'amino acids' where each codon gets its own unique character symbol. These characters should be reserved only for representing the 64 individual codons --- note that this...
[ "Represent", "nucleotide", "sequence", "by", "sequence", "of", "codon", "symbols", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L55-L92
zsethna/OLGA
olga/utils.py
cutR_seq
def cutR_seq(seq, cutR, max_palindrome): """Cut genomic sequence from the right. Parameters ---------- seq : str Nucleotide sequence to be cut from the right cutR : int cutR - max_palindrome = how many nucleotides to cut from the right. Negative cutR implies complementary pa...
python
def cutR_seq(seq, cutR, max_palindrome): """Cut genomic sequence from the right. Parameters ---------- seq : str Nucleotide sequence to be cut from the right cutR : int cutR - max_palindrome = how many nucleotides to cut from the right. Negative cutR implies complementary pa...
[ "def", "cutR_seq", "(", "seq", ",", "cutR", ",", "max_palindrome", ")", ":", "complement_dict", "=", "{", "'A'", ":", "'T'", ",", "'C'", ":", "'G'", ",", "'G'", ":", "'C'", ",", "'T'", ":", "'A'", "}", "#can include lower case if wanted", "if", "cutR", ...
Cut genomic sequence from the right. Parameters ---------- seq : str Nucleotide sequence to be cut from the right cutR : int cutR - max_palindrome = how many nucleotides to cut from the right. Negative cutR implies complementary palindromic insertions. max_palindrome : int ...
[ "Cut", "genomic", "sequence", "from", "the", "right", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L95-L127
zsethna/OLGA
olga/utils.py
cutL_seq
def cutL_seq(seq, cutL, max_palindrome): """Cut genomic sequence from the left. Parameters ---------- seq : str Nucleotide sequence to be cut from the right cutL : int cutL - max_palindrome = how many nucleotides to cut from the left. Negative cutL implies complementary pali...
python
def cutL_seq(seq, cutL, max_palindrome): """Cut genomic sequence from the left. Parameters ---------- seq : str Nucleotide sequence to be cut from the right cutL : int cutL - max_palindrome = how many nucleotides to cut from the left. Negative cutL implies complementary pali...
[ "def", "cutL_seq", "(", "seq", ",", "cutL", ",", "max_palindrome", ")", ":", "complement_dict", "=", "{", "'A'", ":", "'T'", ",", "'C'", ":", "'G'", ",", "'G'", ":", "'C'", ",", "'T'", ":", "'A'", "}", "#can include lower case if wanted", "if", "cutL", ...
Cut genomic sequence from the left. Parameters ---------- seq : str Nucleotide sequence to be cut from the right cutL : int cutL - max_palindrome = how many nucleotides to cut from the left. Negative cutL implies complementary palindromic insertions. max_palindrome : int ...
[ "Cut", "genomic", "sequence", "from", "the", "left", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L129-L162
zsethna/OLGA
olga/utils.py
construct_codons_dict
def construct_codons_dict(alphabet_file = None): """Generate the sub_codons_right dictionary of codon suffixes. syntax of custom alphabet_files: char: list,of,amino,acids,or,codons,separated,by,commas Parameters ---------- alphabet_file : str File name for a custom al...
python
def construct_codons_dict(alphabet_file = None): """Generate the sub_codons_right dictionary of codon suffixes. syntax of custom alphabet_files: char: list,of,amino,acids,or,codons,separated,by,commas Parameters ---------- alphabet_file : str File name for a custom al...
[ "def", "construct_codons_dict", "(", "alphabet_file", "=", "None", ")", ":", "#Some symbols can't be used in the CDR3 sequences in order to allow for", "#regular expression parsing and general manipulation.", "protected_symbols", "=", "[", "' '", ",", "'\\t'", ",", "'\\n'", ",", ...
Generate the sub_codons_right dictionary of codon suffixes. syntax of custom alphabet_files: char: list,of,amino,acids,or,codons,separated,by,commas Parameters ---------- alphabet_file : str File name for a custom alphabet definition. If no file is provided, the ...
[ "Generate", "the", "sub_codons_right", "dictionary", "of", "codon", "suffixes", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L165-L259
zsethna/OLGA
olga/utils.py
generate_sub_codons_left
def generate_sub_codons_left(codons_dict): """Generate the sub_codons_left dictionary of codon prefixes. Parameters ---------- codons_dict : dict Dictionary, keyed by the allowed 'amino acid' symbols with the values being lists of codons corresponding to the symbol. Returns --...
python
def generate_sub_codons_left(codons_dict): """Generate the sub_codons_left dictionary of codon prefixes. Parameters ---------- codons_dict : dict Dictionary, keyed by the allowed 'amino acid' symbols with the values being lists of codons corresponding to the symbol. Returns --...
[ "def", "generate_sub_codons_left", "(", "codons_dict", ")", ":", "sub_codons_left", "=", "{", "}", "for", "aa", "in", "codons_dict", ".", "keys", "(", ")", ":", "sub_codons_left", "[", "aa", "]", "=", "list", "(", "set", "(", "[", "x", "[", "0", "]", ...
Generate the sub_codons_left dictionary of codon prefixes. Parameters ---------- codons_dict : dict Dictionary, keyed by the allowed 'amino acid' symbols with the values being lists of codons corresponding to the symbol. Returns ------- sub_codons_left : dict Dictionar...
[ "Generate", "the", "sub_codons_left", "dictionary", "of", "codon", "prefixes", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L261-L281
zsethna/OLGA
olga/utils.py
generate_sub_codons_right
def generate_sub_codons_right(codons_dict): """Generate the sub_codons_right dictionary of codon suffixes. Parameters ---------- codons_dict : dict Dictionary, keyed by the allowed 'amino acid' symbols with the values being lists of codons corresponding to the symbol. Returns ...
python
def generate_sub_codons_right(codons_dict): """Generate the sub_codons_right dictionary of codon suffixes. Parameters ---------- codons_dict : dict Dictionary, keyed by the allowed 'amino acid' symbols with the values being lists of codons corresponding to the symbol. Returns ...
[ "def", "generate_sub_codons_right", "(", "codons_dict", ")", ":", "sub_codons_right", "=", "{", "}", "for", "aa", "in", "codons_dict", ".", "keys", "(", ")", ":", "sub_codons_right", "[", "aa", "]", "=", "list", "(", "set", "(", "[", "x", "[", "-", "1"...
Generate the sub_codons_right dictionary of codon suffixes. Parameters ---------- codons_dict : dict Dictionary, keyed by the allowed 'amino acid' symbols with the values being lists of codons corresponding to the symbol. Returns ------- sub_codons_right : dict Diction...
[ "Generate", "the", "sub_codons_right", "dictionary", "of", "codon", "suffixes", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L283-L303
zsethna/OLGA
olga/utils.py
determine_seq_type
def determine_seq_type(seq, aa_alphabet): """Determine the type of a sequence. Parameters ---------- seq : str Sequence to be typed. aa_alphabet : str String of all characters recoginized as 'amino acids'. (i.e. the keys of codons_dict: aa_alphabet = ''.join(codons_dict...
python
def determine_seq_type(seq, aa_alphabet): """Determine the type of a sequence. Parameters ---------- seq : str Sequence to be typed. aa_alphabet : str String of all characters recoginized as 'amino acids'. (i.e. the keys of codons_dict: aa_alphabet = ''.join(codons_dict...
[ "def", "determine_seq_type", "(", "seq", ",", "aa_alphabet", ")", ":", "if", "all", "(", "[", "x", "in", "'ACGTacgt'", "for", "x", "in", "seq", "]", ")", ":", "return", "'ntseq'", "elif", "all", "(", "[", "x", "in", "aa_alphabet", "for", "x", "in", ...
Determine the type of a sequence. Parameters ---------- seq : str Sequence to be typed. aa_alphabet : str String of all characters recoginized as 'amino acids'. (i.e. the keys of codons_dict: aa_alphabet = ''.join(codons_dict.keys()) ) Returns ------- seq_type...
[ "Determine", "the", "type", "of", "a", "sequence", ".", "Parameters", "----------" ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L305-L336
zsethna/OLGA
olga/utils.py
calc_steady_state_dist
def calc_steady_state_dist(R): """Calculate the steady state dist of a 4 state markov transition matrix. Parameters ---------- R : ndarray Markov transition matrix Returns ------- p_ss : ndarray Steady state probability distribution """ #Calc steady state d...
python
def calc_steady_state_dist(R): """Calculate the steady state dist of a 4 state markov transition matrix. Parameters ---------- R : ndarray Markov transition matrix Returns ------- p_ss : ndarray Steady state probability distribution """ #Calc steady state d...
[ "def", "calc_steady_state_dist", "(", "R", ")", ":", "#Calc steady state distribution for a dinucleotide bias matrix", "w", ",", "v", "=", "np", ".", "linalg", ".", "eig", "(", "R", ")", "for", "i", "in", "range", "(", "4", ")", ":", "if", "np", ".", "abs"...
Calculate the steady state dist of a 4 state markov transition matrix. Parameters ---------- R : ndarray Markov transition matrix Returns ------- p_ss : ndarray Steady state probability distribution
[ "Calculate", "the", "steady", "state", "dist", "of", "a", "4", "state", "markov", "transition", "matrix", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/utils.py#L340-L361
zsethna/OLGA
olga/sequence_generation.py
rnd_ins_seq
def rnd_ins_seq(ins_len, C_R, CP_first_nt): """Generate a random insertion nucleotide sequence of length ins_len. Draws the sequence identity (for a set length) from the distribution defined by the dinucleotide markov model of transition matrix R. Parameters ---------- ins_len : int Le...
python
def rnd_ins_seq(ins_len, C_R, CP_first_nt): """Generate a random insertion nucleotide sequence of length ins_len. Draws the sequence identity (for a set length) from the distribution defined by the dinucleotide markov model of transition matrix R. Parameters ---------- ins_len : int Le...
[ "def", "rnd_ins_seq", "(", "ins_len", ",", "C_R", ",", "CP_first_nt", ")", ":", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",", "'T'", ":", "3", "}", "num2nt", "=", "'ACGT'", "if", "ins_len", "==", "0", ":"...
Generate a random insertion nucleotide sequence of length ins_len. Draws the sequence identity (for a set length) from the distribution defined by the dinucleotide markov model of transition matrix R. Parameters ---------- ins_len : int Length of nucleotide sequence to be inserted. C_R...
[ "Generate", "a", "random", "insertion", "nucleotide", "sequence", "of", "length", "ins_len", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/sequence_generation.py#L457-L502
zsethna/OLGA
olga/sequence_generation.py
SequenceGenerationVDJ.gen_rnd_prod_CDR3
def gen_rnd_prod_CDR3(self, conserved_J_residues = 'FVW'): """Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F...
python
def gen_rnd_prod_CDR3(self, conserved_J_residues = 'FVW'): """Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F...
[ "def", "gen_rnd_prod_CDR3", "(", "self", ",", "conserved_J_residues", "=", "'FVW'", ")", ":", "coding_pass", "=", "False", "while", "~", "coding_pass", ":", "recomb_events", "=", "self", ".", "choose_random_recomb_events", "(", ")", "V_seq", "=", "self", ".", ...
Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F, V, and/or W) Returns ------- ntseq : str ...
[ "Generate", "a", "productive", "CDR3", "seq", "from", "a", "Monte", "Carlo", "draw", "of", "the", "model", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/sequence_generation.py#L187-L243
zsethna/OLGA
olga/sequence_generation.py
SequenceGenerationVDJ.choose_random_recomb_events
def choose_random_recomb_events(self): """Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. ...
python
def choose_random_recomb_events(self): """Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. ...
[ "def", "choose_random_recomb_events", "(", "self", ")", ":", "recomb_events", "=", "{", "}", "recomb_events", "[", "'V'", "]", "=", "self", ".", "CPV", ".", "searchsorted", "(", "np", ".", "random", ".", "random", "(", ")", ")", "#For 2D arrays make sure to ...
Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. Example -------- >>> sequence...
[ "Sample", "the", "genomic", "model", "for", "VDJ", "recombination", "events", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/sequence_generation.py#L245-L283
zsethna/OLGA
olga/sequence_generation.py
SequenceGenerationVJ.gen_rnd_prod_CDR3
def gen_rnd_prod_CDR3(self, conserved_J_residues = 'FVW'): """Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F...
python
def gen_rnd_prod_CDR3(self, conserved_J_residues = 'FVW'): """Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F...
[ "def", "gen_rnd_prod_CDR3", "(", "self", ",", "conserved_J_residues", "=", "'FVW'", ")", ":", "coding_pass", "=", "False", "while", "~", "coding_pass", ":", "recomb_events", "=", "self", ".", "choose_random_recomb_events", "(", ")", "V_seq", "=", "self", ".", ...
Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F, V, and/or W) Returns ------- ntseq : str ...
[ "Generate", "a", "productive", "CDR3", "seq", "from", "a", "Monte", "Carlo", "draw", "of", "the", "model", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/sequence_generation.py#L368-L422
zsethna/OLGA
olga/sequence_generation.py
SequenceGenerationVJ.choose_random_recomb_events
def choose_random_recomb_events(self): """Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. ...
python
def choose_random_recomb_events(self): """Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. ...
[ "def", "choose_random_recomb_events", "(", "self", ")", ":", "recomb_events", "=", "{", "}", "#For 2D arrays make sure to take advantage of a mod expansion to find indicies", "VJ_choice", "=", "self", ".", "CPVJ", ".", "searchsorted", "(", "np", ".", "random", ".", "ran...
Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. Example -------- >>> sequence...
[ "Sample", "the", "genomic", "model", "for", "VDJ", "recombination", "events", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/sequence_generation.py#L424-L454
evonove/django-money-rates
djmoney_rates/backends.py
BaseRateBackend.update_rates
def update_rates(self): """ Creates or updates rates for a source """ source, created = RateSource.objects.get_or_create(name=self.get_source_name()) source.base_currency = self.get_base_currency() source.save() for currency, value in six.iteritems(self.get_rates...
python
def update_rates(self): """ Creates or updates rates for a source """ source, created = RateSource.objects.get_or_create(name=self.get_source_name()) source.base_currency = self.get_base_currency() source.save() for currency, value in six.iteritems(self.get_rates...
[ "def", "update_rates", "(", "self", ")", ":", "source", ",", "created", "=", "RateSource", ".", "objects", ".", "get_or_create", "(", "name", "=", "self", ".", "get_source_name", "(", ")", ")", "source", ".", "base_currency", "=", "self", ".", "get_base_cu...
Creates or updates rates for a source
[ "Creates", "or", "updates", "rates", "for", "a", "source" ]
train
https://github.com/evonove/django-money-rates/blob/ac1f7636b9a38d3e153eb833019342c4d88634c2/djmoney_rates/backends.py#L52-L67
tansey/gfl
pygfl/bayes.py
sample_gtf
def sample_gtf(data, D, k, likelihood='gaussian', prior='laplace', lambda_hyperparams=None, lam_walk_stdev=0.01, lam0=1., dp_hyperparameter=None, w_hyperparameters=None, iterations=7000, burn=2000, thin=10, robus...
python
def sample_gtf(data, D, k, likelihood='gaussian', prior='laplace', lambda_hyperparams=None, lam_walk_stdev=0.01, lam0=1., dp_hyperparameter=None, w_hyperparameters=None, iterations=7000, burn=2000, thin=10, robus...
[ "def", "sample_gtf", "(", "data", ",", "D", ",", "k", ",", "likelihood", "=", "'gaussian'", ",", "prior", "=", "'laplace'", ",", "lambda_hyperparams", "=", "None", ",", "lam_walk_stdev", "=", "0.01", ",", "lam0", "=", "1.", ",", "dp_hyperparameter", "=", ...
Generate samples from the generalized graph trend filtering distribution via a modified Swendsen-Wang slice sampling algorithm. Options for likelihood: gaussian, binomial, poisson. Options for prior: laplace, doublepareto.
[ "Generate", "samples", "from", "the", "generalized", "graph", "trend", "filtering", "distribution", "via", "a", "modified", "Swendsen", "-", "Wang", "slice", "sampling", "algorithm", ".", "Options", "for", "likelihood", ":", "gaussian", "binomial", "poisson", ".",...
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/bayes.py#L138-L274
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.compute_regex_CDR3_template_pgen
def compute_regex_CDR3_template_pgen(self, regex_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True, raise_overload_warning = True): """Compute Pgen for all seqs consistent with regular expression regex_seq. Computes Pgen for a (limited vocabulary) regular expression of CDR3...
python
def compute_regex_CDR3_template_pgen(self, regex_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True, raise_overload_warning = True): """Compute Pgen for all seqs consistent with regular expression regex_seq. Computes Pgen for a (limited vocabulary) regular expression of CDR3...
[ "def", "compute_regex_CDR3_template_pgen", "(", "self", ",", "regex_seq", ",", "V_usage_mask_in", "=", "None", ",", "J_usage_mask_in", "=", "None", ",", "print_warnings", "=", "True", ",", "raise_overload_warning", "=", "True", ")", ":", "V_usage_mask", ",", "J_us...
Compute Pgen for all seqs consistent with regular expression regex_seq. Computes Pgen for a (limited vocabulary) regular expression of CDR3 amino acid sequences, conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. Please note ...
[ "Compute", "Pgen", "for", "all", "seqs", "consistent", "with", "regular", "expression", "regex_seq", ".", "Computes", "Pgen", "for", "a", "(", "limited", "vocabulary", ")", "regular", "expression", "of", "CDR3", "amino", "acid", "sequences", "conditioned", "on",...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L156-L213
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.compute_aa_CDR3_pgen
def compute_aa_CDR3_pgen(self, CDR3_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen for the amino acid sequence CDR3_seq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Examples are T...
python
def compute_aa_CDR3_pgen(self, CDR3_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen for the amino acid sequence CDR3_seq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Examples are T...
[ "def", "compute_aa_CDR3_pgen", "(", "self", ",", "CDR3_seq", ",", "V_usage_mask_in", "=", "None", ",", "J_usage_mask_in", "=", "None", ",", "print_warnings", "=", "True", ")", ":", "if", "len", "(", "CDR3_seq", ")", "==", "0", ":", "return", "0", "for", ...
Compute Pgen for the amino acid sequence CDR3_seq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Examples are TCRB sequences/model) Parameters ---------- CDR3_seq : str CDR3 sequence composed of...
[ "Compute", "Pgen", "for", "the", "amino", "acid", "sequence", "CDR3_seq", ".", "Conditioned", "on", "the", "V", "genes", "/", "alleles", "indicated", "in", "V_usage_mask_in", "and", "the", "J", "genes", "/", "alleles", "in", "J_usage_mask_in", ".", "(", "Exa...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L216-L264
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.compute_hamming_dist_1_pgen
def compute_hamming_dist_1_pgen(self, CDR3_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen of all seqs hamming dist 1 (in amino acids) from CDR3_seq. Please note that this function will list out all the sequences that are hamming distance 1 from...
python
def compute_hamming_dist_1_pgen(self, CDR3_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen of all seqs hamming dist 1 (in amino acids) from CDR3_seq. Please note that this function will list out all the sequences that are hamming distance 1 from...
[ "def", "compute_hamming_dist_1_pgen", "(", "self", ",", "CDR3_seq", ",", "V_usage_mask_in", "=", "None", ",", "J_usage_mask_in", "=", "None", ",", "print_warnings", "=", "True", ")", ":", "#make sure that the symbol X is defined as the fully undetermined amino acid:", "#X ~...
Compute Pgen of all seqs hamming dist 1 (in amino acids) from CDR3_seq. Please note that this function will list out all the sequences that are hamming distance 1 from the base sequence and then calculate the Pgen of each sequence in succession. THIS CAN BE SLOW as it computes Pg...
[ "Compute", "Pgen", "of", "all", "seqs", "hamming", "dist", "1", "(", "in", "amino", "acids", ")", "from", "CDR3_seq", ".", "Please", "note", "that", "this", "function", "will", "list", "out", "all", "the", "sequences", "that", "are", "hamming", "distance",...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L266-L316
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.compute_nt_CDR3_pgen
def compute_nt_CDR3_pgen(self, CDR3_ntseq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen for the inframe nucleotide sequence CDR3_ntseq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Ex...
python
def compute_nt_CDR3_pgen(self, CDR3_ntseq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen for the inframe nucleotide sequence CDR3_ntseq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Ex...
[ "def", "compute_nt_CDR3_pgen", "(", "self", ",", "CDR3_ntseq", ",", "V_usage_mask_in", "=", "None", ",", "J_usage_mask_in", "=", "None", ",", "print_warnings", "=", "True", ")", ":", "if", "not", "len", "(", "CDR3_ntseq", ")", "%", "3", "==", "0", ":", "...
Compute Pgen for the inframe nucleotide sequence CDR3_ntseq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Examples are TCRB sequences/model) Parameters ---------- CDR3_ntseq : str Inframe nucle...
[ "Compute", "Pgen", "for", "the", "inframe", "nucleotide", "sequence", "CDR3_ntseq", ".", "Conditioned", "on", "the", "V", "genes", "/", "alleles", "indicated", "in", "V_usage_mask_in", "and", "the", "J", "genes", "/", "alleles", "in", "J_usage_mask_in", ".", "...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L318-L368
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.format_usage_masks
def format_usage_masks(self, V_usage_mask_in, J_usage_mask_in, print_warnings = True): """Format raw usage masks into lists of indices. Usage masks allows the Pgen computation to be conditioned on the V and J gene/allele identities. The inputted masks are lists of strings, or a si...
python
def format_usage_masks(self, V_usage_mask_in, J_usage_mask_in, print_warnings = True): """Format raw usage masks into lists of indices. Usage masks allows the Pgen computation to be conditioned on the V and J gene/allele identities. The inputted masks are lists of strings, or a si...
[ "def", "format_usage_masks", "(", "self", ",", "V_usage_mask_in", ",", "J_usage_mask_in", ",", "print_warnings", "=", "True", ")", ":", "#Format the V usage mask", "if", "V_usage_mask_in", "is", "None", ":", "#Default case, use all productive V genes with non-zero probability...
Format raw usage masks into lists of indices. Usage masks allows the Pgen computation to be conditioned on the V and J gene/allele identities. The inputted masks are lists of strings, or a single string, of the names of the genes or alleles to be conditioned on. The default mask ...
[ "Format", "raw", "usage", "masks", "into", "lists", "of", "indices", ".", "Usage", "masks", "allows", "the", "Pgen", "computation", "to", "be", "conditioned", "on", "the", "V", "and", "J", "gene", "/", "allele", "identities", ".", "The", "inputted", "masks...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L377-L470
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.list_seqs_from_regex
def list_seqs_from_regex(self, regex_seq, print_warnings = True, raise_overload_warning = True): """List sequences that match regular expression template. This function parses a limited regular expression vocabulary, and lists all the sequences consistent with the regular expression. Suppo...
python
def list_seqs_from_regex(self, regex_seq, print_warnings = True, raise_overload_warning = True): """List sequences that match regular expression template. This function parses a limited regular expression vocabulary, and lists all the sequences consistent with the regular expression. Suppo...
[ "def", "list_seqs_from_regex", "(", "self", ",", "regex_seq", ",", "print_warnings", "=", "True", ",", "raise_overload_warning", "=", "True", ")", ":", "aa_symbols", "=", "''", ".", "join", "(", "self", ".", "codons_dict", ")", "default_max_reps", "=", "40", ...
List sequences that match regular expression template. This function parses a limited regular expression vocabulary, and lists all the sequences consistent with the regular expression. Supported regex syntax: [] and {}. Cannot have two {} in a row. Note we can't use Kline star (*...
[ "List", "sequences", "that", "match", "regular", "expression", "template", ".", "This", "function", "parses", "a", "limited", "regular", "expression", "vocabulary", "and", "lists", "all", "the", "sequences", "consistent", "with", "the", "regular", "expression", "....
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L472-L601
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.max_nt_to_aa_alignment_left
def max_nt_to_aa_alignment_left(self, CDR3_seq, ntseq): """Find maximum match between CDR3_seq and ntseq from the left. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the left (or 5' end) that is consistent with the 'amino...
python
def max_nt_to_aa_alignment_left(self, CDR3_seq, ntseq): """Find maximum match between CDR3_seq and ntseq from the left. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the left (or 5' end) that is consistent with the 'amino...
[ "def", "max_nt_to_aa_alignment_left", "(", "self", ",", "CDR3_seq", ",", "ntseq", ")", ":", "max_alignment", "=", "0", "if", "len", "(", "ntseq", ")", "==", "0", ":", "return", "0", "aa_aligned", "=", "True", "while", "aa_aligned", ":", "if", "ntseq", "[...
Find maximum match between CDR3_seq and ntseq from the left. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the left (or 5' end) that is consistent with the 'amino acid' sequence CDR3_seq. Parameters ---------- ...
[ "Find", "maximum", "match", "between", "CDR3_seq", "and", "ntseq", "from", "the", "left", ".", "This", "function", "returns", "the", "length", "of", "the", "maximum", "length", "nucleotide", "subsequence", "of", "ntseq", "contiguous", "from", "the", "left", "(...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L604-L652
zsethna/OLGA
olga/generation_probability.py
GenerationProbability.max_nt_to_aa_alignment_right
def max_nt_to_aa_alignment_right(self, CDR3_seq, ntseq): """Find maximum match between CDR3_seq and ntseq from the right. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the right (or 3' end) that is consistent with the 'amino ...
python
def max_nt_to_aa_alignment_right(self, CDR3_seq, ntseq): """Find maximum match between CDR3_seq and ntseq from the right. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the right (or 3' end) that is consistent with the 'amino ...
[ "def", "max_nt_to_aa_alignment_right", "(", "self", ",", "CDR3_seq", ",", "ntseq", ")", ":", "r_CDR3_seq", "=", "CDR3_seq", "[", ":", ":", "-", "1", "]", "#reverse CDR3_seq", "r_ntseq", "=", "ntseq", "[", ":", ":", "-", "1", "]", "#reverse ntseq", "max_ali...
Find maximum match between CDR3_seq and ntseq from the right. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the right (or 3' end) that is consistent with the 'amino acid' sequence CDR3_seq Parameters ---------- ...
[ "Find", "maximum", "match", "between", "CDR3_seq", "and", "ntseq", "from", "the", "right", ".", "This", "function", "returns", "the", "length", "of", "the", "maximum", "length", "nucleotide", "subsequence", "of", "ntseq", "contiguous", "from", "the", "right", ...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L654-L703
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVDJ.compute_CDR3_pgen
def compute_CDR3_pgen(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VDJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. (Examples are TCRB seq...
python
def compute_CDR3_pgen(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VDJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. (Examples are TCRB seq...
[ "def", "compute_CDR3_pgen", "(", "self", ",", "CDR3_seq", ",", "V_usage_mask", ",", "J_usage_mask", ")", ":", "#Genomic V alignment/matching (contribution from P(V, delV)), return Pi_V", "Pi_V", ",", "max_V_align", "=", "self", ".", "compute_Pi_V", "(", "CDR3_seq", ",", ...
Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VDJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. (Examples are TCRB sequences/model) Parameters ---------- CDR3_seq : st...
[ "Compute", "Pgen", "for", "CDR3", "amino", "acid", "sequence", "CDR3_seq", "from", "VDJ", "model", ".", "Conditioned", "on", "the", "already", "formatted", "V", "genes", "/", "alleles", "indicated", "in", "V_usage_mask", "and", "the", "J", "genes", "/", "all...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L849-L904
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVDJ.compute_Pi_V
def compute_Pi_V(self, CDR3_seq, V_usage_mask): """Compute Pi_V. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V). This corresponds to V_{x_1}. For clarity in parsing the algorithm implementation, we include which ...
python
def compute_Pi_V(self, CDR3_seq, V_usage_mask): """Compute Pi_V. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V). This corresponds to V_{x_1}. For clarity in parsing the algorithm implementation, we include which ...
[ "def", "compute_Pi_V", "(", "self", ",", "CDR3_seq", ",", "V_usage_mask", ")", ":", "#Note, the cutV_genomic_CDR3_segs INCLUDE the palindromic insertions and thus are max_palindrome nts longer than the template.", "#furthermore, the genomic sequence should be pruned to start at the conserved C...
Compute Pi_V. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V). This corresponds to V_{x_1}. For clarity in parsing the algorithm implementation, we include which instance attributes are used in the method as 'param...
[ "Compute", "Pi_V", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "V", "genomic", "contributions", "P", "(", "V", ")", "*", "P", "(", "delV|V", ")", ".", "This", "corresponds", "to", "V_", "{",...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L907-L968
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVDJ.compute_Pi_L
def compute_Pi_L(self, CDR3_seq, Pi_V, max_V_align): """Compute Pi_L. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V), and the VD (N1) insertions, first_nt_bias_insVD(m_1)PinsVD(\ell_{VD})\prod_{i=2}^{\ell_{VD}}Rvd(m_i|m_{i-1...
python
def compute_Pi_L(self, CDR3_seq, Pi_V, max_V_align): """Compute Pi_L. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V), and the VD (N1) insertions, first_nt_bias_insVD(m_1)PinsVD(\ell_{VD})\prod_{i=2}^{\ell_{VD}}Rvd(m_i|m_{i-1...
[ "def", "compute_Pi_L", "(", "self", ",", "CDR3_seq", ",", "Pi_V", ",", "max_V_align", ")", ":", "#max_insertions = 30 #len(PinsVD) - 1 should zeropad the last few spots", "max_insertions", "=", "len", "(", "self", ".", "PinsVD", ")", "-", "1", "Pi_L", "=", "np", "...
Compute Pi_L. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V), and the VD (N1) insertions, first_nt_bias_insVD(m_1)PinsVD(\ell_{VD})\prod_{i=2}^{\ell_{VD}}Rvd(m_i|m_{i-1}). This corresponds to V_{x_1}{M^{x_1}}_{x_2}. ...
[ "Compute", "Pi_L", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "V", "genomic", "contributions", "P", "(", "V", ")", "*", "P", "(", "delV|V", ")", "and", "the", "VD", "(", "N1", ")", "inser...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L971-L1088
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVDJ.compute_Pi_J_given_D
def compute_Pi_J_given_D(self, CDR3_seq, J_usage_mask): """Compute Pi_J conditioned on D. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J) = P(D|J)P(J)P(delJ|J). This corresponds to J(D)^{x_4}. For c...
python
def compute_Pi_J_given_D(self, CDR3_seq, J_usage_mask): """Compute Pi_J conditioned on D. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J) = P(D|J)P(J)P(delJ|J). This corresponds to J(D)^{x_4}. For c...
[ "def", "compute_Pi_J_given_D", "(", "self", ",", "CDR3_seq", ",", "J_usage_mask", ")", ":", "#Note, the cutJ_genomic_CDR3_segs INCLUDE the palindromic insertions and thus are max_palindrome nts longer than the template.", "#furthermore, the genomic sequence should be pruned to start at a conse...
Compute Pi_J conditioned on D. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J) = P(D|J)P(J)P(delJ|J). This corresponds to J(D)^{x_4}. For clarity in parsing the algorithm implementation, we include which ...
[ "Compute", "Pi_J", "conditioned", "on", "D", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "D", "and", "J", "genomic", "contributions", "P", "(", "D", "J", ")", "*", "P", "(", "delJ|J", ")", ...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L1091-L1159
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVDJ.compute_Pi_JinsDJ_given_D
def compute_Pi_JinsDJ_given_D(self, CDR3_seq, Pi_J_given_D, max_J_align): """Compute Pi_JinsDJ conditioned on D. This function returns the Pi array from the model factors of the J genomic contributions, P(D,J)*P(delJ|J), and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\e...
python
def compute_Pi_JinsDJ_given_D(self, CDR3_seq, Pi_J_given_D, max_J_align): """Compute Pi_JinsDJ conditioned on D. This function returns the Pi array from the model factors of the J genomic contributions, P(D,J)*P(delJ|J), and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\e...
[ "def", "compute_Pi_JinsDJ_given_D", "(", "self", ",", "CDR3_seq", ",", "Pi_J_given_D", ",", "max_J_align", ")", ":", "#max_insertions = 30 #len(PinsVD) - 1 should zeropad the last few spots", "max_insertions", "=", "len", "(", "self", ".", "PinsDJ", ")", "-", "1", "Pi_J...
Compute Pi_JinsDJ conditioned on D. This function returns the Pi array from the model factors of the J genomic contributions, P(D,J)*P(delJ|J), and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\ell_{DJ})\prod_{i=2}^{\ell_{DJ}}Rdj(n_i|n_{i-1}) conditioned on D identity. T...
[ "Compute", "Pi_JinsDJ", "conditioned", "on", "D", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "J", "genomic", "contributions", "P", "(", "D", "J", ")", "*", "P", "(", "delJ|J", ")", "and", "...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L1162-L1282
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVDJ.compute_Pi_R
def compute_Pi_R(self, CDR3_seq, Pi_JinsDJ_given_D): """Compute Pi_R. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J)P(delDl, delDr |D) and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\ell_{DJ})\pr...
python
def compute_Pi_R(self, CDR3_seq, Pi_JinsDJ_given_D): """Compute Pi_R. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J)P(delDl, delDr |D) and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\ell_{DJ})\pr...
[ "def", "compute_Pi_R", "(", "self", ",", "CDR3_seq", ",", "Pi_JinsDJ_given_D", ")", ":", "#Need to consider all D alignments from all possible positions and right deletions.", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",", "'...
Compute Pi_R. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J)P(delDl, delDr |D) and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\ell_{DJ})\prod_{i=2}^{\ell_{DJ}}Rdj(n_i|n_{i-1}). This corresponds t...
[ "Compute", "Pi_R", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "D", "and", "J", "genomic", "contributions", "P", "(", "D", "J", ")", "*", "P", "(", "delJ|J", ")", "P", "(", "delDl", "delDr...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L1285-L1521
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVJ.compute_CDR3_pgen
def compute_CDR3_pgen(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. Parameters ...
python
def compute_CDR3_pgen(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. Parameters ...
[ "def", "compute_CDR3_pgen", "(", "self", ",", "CDR3_seq", ",", "V_usage_mask", ",", "J_usage_mask", ")", ":", "#Genomic J alignment/matching (contribution from P(delJ | J)), return Pi_J and reduced J_usage_mask", "Pi_J", ",", "r_J_usage_mask", "=", "self", ".", "compute_Pi_J", ...
Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. Parameters ---------- CDR3_seq : str CDR3 sequence composed of 'amino...
[ "Compute", "Pgen", "for", "CDR3", "amino", "acid", "sequence", "CDR3_seq", "from", "VJ", "model", ".", "Conditioned", "on", "the", "already", "formatted", "V", "genes", "/", "alleles", "indicated", "in", "V_usage_mask", "and", "the", "J", "genes", "/", "alle...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L1630-L1676
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVJ.compute_Pi_V_given_J
def compute_Pi_V_given_J(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pi_V conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V). This corresponds to V(J)_{x_1}. For clarity in parsing the a...
python
def compute_Pi_V_given_J(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pi_V conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V). This corresponds to V(J)_{x_1}. For clarity in parsing the a...
[ "def", "compute_Pi_V_given_J", "(", "self", ",", "CDR3_seq", ",", "V_usage_mask", ",", "J_usage_mask", ")", ":", "#Note, the cutV_genomic_CDR3_segs INCLUDE the palindromic insertions and thus are max_palindrome nts longer than the template.", "#furthermore, the genomic sequence should be p...
Compute Pi_V conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V). This corresponds to V(J)_{x_1}. For clarity in parsing the algorithm implementation, we include which instance attributes are used i...
[ "Compute", "Pi_V", "conditioned", "on", "J", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "V", "genomic", "contributions", "P", "(", "V", "J", ")", "*", "P", "(", "delV|V", ")", ".", "This", ...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L1679-L1746
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVJ.compute_Pi_V_insVJ_given_J
def compute_Pi_V_insVJ_given_J(self, CDR3_seq, Pi_V_given_J, max_V_align): """Compute Pi_V_insVJ conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V), and the VJ (N) insertions, first_nt_bias_insVJ(m_1)PinsVJ(...
python
def compute_Pi_V_insVJ_given_J(self, CDR3_seq, Pi_V_given_J, max_V_align): """Compute Pi_V_insVJ conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V), and the VJ (N) insertions, first_nt_bias_insVJ(m_1)PinsVJ(...
[ "def", "compute_Pi_V_insVJ_given_J", "(", "self", ",", "CDR3_seq", ",", "Pi_V_given_J", ",", "max_V_align", ")", ":", "#max_insertions = 30 #len(PinsVJ) - 1 should zeropad the last few spots", "max_insertions", "=", "len", "(", "self", ".", "PinsVJ", ")", "-", "1", "Pi_...
Compute Pi_V_insVJ conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V), and the VJ (N) insertions, first_nt_bias_insVJ(m_1)PinsVJ(\ell_{VJ})\prod_{i=2}^{\ell_{VJ}}Rvj(m_i|m_{i-1}). This corresponds to V(J)_{...
[ "Compute", "Pi_V_insVJ", "conditioned", "on", "J", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "V", "genomic", "contributions", "P", "(", "V", "J", ")", "*", "P", "(", "delV|V", ")", "and", ...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L1749-L1868
zsethna/OLGA
olga/generation_probability.py
GenerationProbabilityVJ.compute_Pi_J
def compute_Pi_J(self, CDR3_seq, J_usage_mask): """Compute Pi_J. This function returns the Pi array from the model factors of the J genomic contributions, P(delJ|J). This corresponds to J(D)^{x_4}. For clarity in parsing the algorithm implementation, we include which ...
python
def compute_Pi_J(self, CDR3_seq, J_usage_mask): """Compute Pi_J. This function returns the Pi array from the model factors of the J genomic contributions, P(delJ|J). This corresponds to J(D)^{x_4}. For clarity in parsing the algorithm implementation, we include which ...
[ "def", "compute_Pi_J", "(", "self", ",", "CDR3_seq", ",", "J_usage_mask", ")", ":", "#Note, the cutJ_genomic_CDR3_segs INCLUDE the palindromic insertions and thus are max_palindrome nts longer than the template.", "#furthermore, the genomic sequence should be pruned to start at a conserved reg...
Compute Pi_J. This function returns the Pi array from the model factors of the J genomic contributions, P(delJ|J). This corresponds to J(D)^{x_4}. For clarity in parsing the algorithm implementation, we include which instance attributes are used in the method as 'paramete...
[ "Compute", "Pi_J", ".", "This", "function", "returns", "the", "Pi", "array", "from", "the", "model", "factors", "of", "the", "J", "genomic", "contributions", "P", "(", "delJ|J", ")", ".", "This", "corresponds", "to", "J", "(", "D", ")", "^", "{", "x_4"...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/generation_probability.py#L1871-L1935
tansey/gfl
pygfl/trendfiltering.py
TrendFilteringSolver.solve
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf(self.nnodes, self.y, self.weights, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.astype('int32'), self.D...
python
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf(self.nnodes, self.y, self.weights, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.astype('int32'), self.D...
[ "def", "solve", "(", "self", ",", "lam", ")", ":", "s", "=", "weighted_graphtf", "(", "self", ".", "nnodes", ",", "self", ".", "y", ",", "self", ".", "weights", ",", "lam", ",", "self", ".", "Dk", ".", "shape", "[", "0", "]", ",", "self", ".", ...
Solves the GFL for a fixed value of lambda.
[ "Solves", "the", "GFL", "for", "a", "fixed", "value", "of", "lambda", "." ]
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/trendfiltering.py#L73-L81
tansey/gfl
pygfl/trendfiltering.py
TrendFilteringSolver.solution_path
def solution_path(self, min_lambda, max_lambda, lambda_bins, verbose=0): '''Follows the solution path to find the best lambda value.''' self.u = np.zeros(self.Dk.shape[0], dtype='double') lambda_grid = np.exp(np.linspace(np.log(max_lambda), np.log(min_lambda), lambda_bins)) aic_trace = n...
python
def solution_path(self, min_lambda, max_lambda, lambda_bins, verbose=0): '''Follows the solution path to find the best lambda value.''' self.u = np.zeros(self.Dk.shape[0], dtype='double') lambda_grid = np.exp(np.linspace(np.log(max_lambda), np.log(min_lambda), lambda_bins)) aic_trace = n...
[ "def", "solution_path", "(", "self", ",", "min_lambda", ",", "max_lambda", ",", "lambda_bins", ",", "verbose", "=", "0", ")", ":", "self", ".", "u", "=", "np", ".", "zeros", "(", "self", ".", "Dk", ".", "shape", "[", "0", "]", ",", "dtype", "=", ...
Follows the solution path to find the best lambda value.
[ "Follows", "the", "solution", "path", "to", "find", "the", "best", "lambda", "value", "." ]
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/trendfiltering.py#L83-L157
tansey/gfl
pygfl/trendfiltering.py
LogitTrendFilteringSolver.solve
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf_logit(self.nnodes, self.trials, self.successes, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.as...
python
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf_logit(self.nnodes, self.trials, self.successes, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.as...
[ "def", "solve", "(", "self", ",", "lam", ")", ":", "s", "=", "weighted_graphtf_logit", "(", "self", ".", "nnodes", ",", "self", ".", "trials", ",", "self", ".", "successes", ",", "lam", ",", "self", ".", "Dk", ".", "shape", "[", "0", "]", ",", "s...
Solves the GFL for a fixed value of lambda.
[ "Solves", "the", "GFL", "for", "a", "fixed", "value", "of", "lambda", "." ]
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/trendfiltering.py#L169-L177
tansey/gfl
pygfl/trendfiltering.py
PoissonTrendFilteringSolver.solve
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf_poisson(self.nnodes, self.obs, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.astype('int32'), se...
python
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf_poisson(self.nnodes, self.obs, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.astype('int32'), se...
[ "def", "solve", "(", "self", ",", "lam", ")", ":", "s", "=", "weighted_graphtf_poisson", "(", "self", ".", "nnodes", ",", "self", ".", "obs", ",", "lam", ",", "self", ".", "Dk", ".", "shape", "[", "0", "]", ",", "self", ".", "Dk", ".", "shape", ...
Solves the GFL for a fixed value of lambda.
[ "Solves", "the", "GFL", "for", "a", "fixed", "value", "of", "lambda", "." ]
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/trendfiltering.py#L188-L196
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParameters.make_V_and_J_mask_mapping
def make_V_and_J_mask_mapping(self, genV, genJ): """Constructs the V and J mask mapping dictionaries. Parameters ---------- genV : list List of genomic V information. genJ : list List of genomic J information. """ ...
python
def make_V_and_J_mask_mapping(self, genV, genJ): """Constructs the V and J mask mapping dictionaries. Parameters ---------- genV : list List of genomic V information. genJ : list List of genomic J information. """ ...
[ "def", "make_V_and_J_mask_mapping", "(", "self", ",", "genV", ",", "genJ", ")", ":", "#construct mapping between allele/gene names and index for custom V_usage_masks", "V_allele_names", "=", "[", "V", "[", "0", "]", "for", "V", "in", "genV", "]", "V_mask_mapping", "="...
Constructs the V and J mask mapping dictionaries. Parameters ---------- genV : list List of genomic V information. genJ : list List of genomic J information.
[ "Constructs", "the", "V", "and", "J", "mask", "mapping", "dictionaries", ".", "Parameters", "----------", "genV", ":", "list", "List", "of", "genomic", "V", "information", ".", "genJ", ":", "list", "List", "of", "genomic", "J", "information", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L157-L195
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParametersVDJ.preprocess_D_segs
def preprocess_D_segs(self, generative_model, genomic_data): """Process P(delDl, delDr|D) into Pi arrays. Sets the attributes PD_nt_pos_vec, PD_2nd_nt_pos_per_aa_vec, min_delDl_given_DdelDr, max_delDl_given_DdelDr, and zeroD_given_D. Parameters ---------- g...
python
def preprocess_D_segs(self, generative_model, genomic_data): """Process P(delDl, delDr|D) into Pi arrays. Sets the attributes PD_nt_pos_vec, PD_2nd_nt_pos_per_aa_vec, min_delDl_given_DdelDr, max_delDl_given_DdelDr, and zeroD_given_D. Parameters ---------- g...
[ "def", "preprocess_D_segs", "(", "self", ",", "generative_model", ",", "genomic_data", ")", ":", "cutD_genomic_CDR3_segs", "=", "genomic_data", ".", "cutD_genomic_CDR3_segs", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",...
Process P(delDl, delDr|D) into Pi arrays. Sets the attributes PD_nt_pos_vec, PD_2nd_nt_pos_per_aa_vec, min_delDl_given_DdelDr, max_delDl_given_DdelDr, and zeroD_given_D. Parameters ---------- generative_model : GenerativeModelVDJ VDJ generative model cl...
[ "Process", "P", "(", "delDl", "delDr|D", ")", "into", "Pi", "arrays", ".", "Sets", "the", "attributes", "PD_nt_pos_vec", "PD_2nd_nt_pos_per_aa_vec", "min_delDl_given_DdelDr", "max_delDl_given_DdelDr", "and", "zeroD_given_D", ".", "Parameters", "----------", "generative_mo...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L463-L541
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParametersVDJ.generate_PJdelJ_nt_pos_vecs
def generate_PJdelJ_nt_pos_vecs(self, generative_model, genomic_data): """Process P(J)*P(delJ|J) into Pi arrays. Sets the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVDJ VDJ gener...
python
def generate_PJdelJ_nt_pos_vecs(self, generative_model, genomic_data): """Process P(J)*P(delJ|J) into Pi arrays. Sets the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVDJ VDJ gener...
[ "def", "generate_PJdelJ_nt_pos_vecs", "(", "self", ",", "generative_model", ",", "genomic_data", ")", ":", "cutJ_genomic_CDR3_segs", "=", "genomic_data", ".", "cutJ_genomic_CDR3_segs", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", ...
Process P(J)*P(delJ|J) into Pi arrays. Sets the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVDJ VDJ generative model class containing the model parameters. genomic_dat...
[ "Process", "P", "(", "J", ")", "*", "P", "(", "delJ|J", ")", "into", "Pi", "arrays", ".", "Sets", "the", "attributes", "PJdelJ_nt_pos_vec", "and", "PJdelJ_2nd_nt_pos_per_aa_vec", ".", "Parameters", "----------", "generative_model", ":", "GenerativeModelVDJ", "VDJ"...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L543-L592
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParametersVDJ.generate_VD_junction_transfer_matrices
def generate_VD_junction_transfer_matrices(self): """Compute the transfer matrices for the VD junction. Sets the attributes Tvd, Svd, Dvd, lTvd, and lDvd. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tvd Tvd ...
python
def generate_VD_junction_transfer_matrices(self): """Compute the transfer matrices for the VD junction. Sets the attributes Tvd, Svd, Dvd, lTvd, and lDvd. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tvd Tvd ...
[ "def", "generate_VD_junction_transfer_matrices", "(", "self", ")", ":", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",", "'T'", ":", "3", "}", "#Compute Tvd", "Tvd", "=", "{", "}", "for", "aa", "in", "self", "."...
Compute the transfer matrices for the VD junction. Sets the attributes Tvd, Svd, Dvd, lTvd, and lDvd.
[ "Compute", "the", "transfer", "matrices", "for", "the", "VD", "junction", ".", "Sets", "the", "attributes", "Tvd", "Svd", "Dvd", "lTvd", "and", "lDvd", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L594-L654
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParametersVDJ.generate_DJ_junction_transfer_matrices
def generate_DJ_junction_transfer_matrices(self): """Compute the transfer matrices for the VD junction. Sets the attributes Tdj, Sdj, Ddj, rTdj, and rDdj. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tdj Tdj = {} for aa...
python
def generate_DJ_junction_transfer_matrices(self): """Compute the transfer matrices for the VD junction. Sets the attributes Tdj, Sdj, Ddj, rTdj, and rDdj. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tdj Tdj = {} for aa...
[ "def", "generate_DJ_junction_transfer_matrices", "(", "self", ")", ":", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",", "'T'", ":", "3", "}", "#Compute Tdj ", "Tdj", "=", "{", "}", "for", "aa", "in", "self", ...
Compute the transfer matrices for the VD junction. Sets the attributes Tdj, Sdj, Ddj, rTdj, and rDdj.
[ "Compute", "the", "transfer", "matrices", "for", "the", "VD", "junction", ".", "Sets", "the", "attributes", "Tdj", "Sdj", "Ddj", "rTdj", "and", "rDdj", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L656-L713
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParametersVJ.generate_PVdelV_nt_pos_vecs
def generate_PVdelV_nt_pos_vecs(self, generative_model, genomic_data): """Process P(delV|V) into Pi arrays. Set the attributes PVdelV_nt_pos_vec and PVdelV_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative mo...
python
def generate_PVdelV_nt_pos_vecs(self, generative_model, genomic_data): """Process P(delV|V) into Pi arrays. Set the attributes PVdelV_nt_pos_vec and PVdelV_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative mo...
[ "def", "generate_PVdelV_nt_pos_vecs", "(", "self", ",", "generative_model", ",", "genomic_data", ")", ":", "cutV_genomic_CDR3_segs", "=", "genomic_data", ".", "cutV_genomic_CDR3_segs", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", ...
Process P(delV|V) into Pi arrays. Set the attributes PVdelV_nt_pos_vec and PVdelV_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative model class containing the model parameters. genomic_data : Geno...
[ "Process", "P", "(", "delV|V", ")", "into", "Pi", "arrays", ".", "Set", "the", "attributes", "PVdelV_nt_pos_vec", "and", "PVdelV_2nd_nt_pos_per_aa_vec", ".", "Parameters", "----------", "generative_model", ":", "GenerativeModelVJ", "VJ", "generative", "model", "class"...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L860-L904
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParametersVJ.generate_PJdelJ_nt_pos_vecs
def generate_PJdelJ_nt_pos_vecs(self, generative_model, genomic_data): """Process P(delJ|J) into Pi arrays. Set the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative mo...
python
def generate_PJdelJ_nt_pos_vecs(self, generative_model, genomic_data): """Process P(delJ|J) into Pi arrays. Set the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative mo...
[ "def", "generate_PJdelJ_nt_pos_vecs", "(", "self", ",", "generative_model", ",", "genomic_data", ")", ":", "cutJ_genomic_CDR3_segs", "=", "genomic_data", ".", "cutJ_genomic_CDR3_segs", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", ...
Process P(delJ|J) into Pi arrays. Set the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative model class containing the model parameters. genomic_data : Geno...
[ "Process", "P", "(", "delJ|J", ")", "into", "Pi", "arrays", ".", "Set", "the", "attributes", "PJdelJ_nt_pos_vec", "and", "PJdelJ_2nd_nt_pos_per_aa_vec", ".", "Parameters", "----------", "generative_model", ":", "GenerativeModelVJ", "VJ", "generative", "model", "class"...
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L906-L953
zsethna/OLGA
olga/preprocess_generative_model_and_data.py
PreprocessedParametersVJ.generate_VJ_junction_transfer_matrices
def generate_VJ_junction_transfer_matrices(self): """Compute the transfer matrices for the VJ junction. Sets the attributes Tvj, Svj, Dvj, lTvj, and lDvj. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tvj Tv...
python
def generate_VJ_junction_transfer_matrices(self): """Compute the transfer matrices for the VJ junction. Sets the attributes Tvj, Svj, Dvj, lTvj, and lDvj. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tvj Tv...
[ "def", "generate_VJ_junction_transfer_matrices", "(", "self", ")", ":", "nt2num", "=", "{", "'A'", ":", "0", ",", "'C'", ":", "1", ",", "'G'", ":", "2", ",", "'T'", ":", "3", "}", "#Compute Tvj", "Tvj", "=", "{", "}", "for", "aa", "in", "self", "."...
Compute the transfer matrices for the VJ junction. Sets the attributes Tvj, Svj, Dvj, lTvj, and lDvj.
[ "Compute", "the", "transfer", "matrices", "for", "the", "VJ", "junction", ".", "Sets", "the", "attributes", "Tvj", "Svj", "Dvj", "lTvj", "and", "lDvj", "." ]
train
https://github.com/zsethna/OLGA/blob/e825c333f0f9a4eb02132e0bcf86f0dca9123114/olga/preprocess_generative_model_and_data.py#L956-L1014
crackinglandia/pype32
tools/readpe.py
showDosHeaderData
def showDosHeaderData(peInstance): """ Prints IMAGE_DOS_HEADER fields. """ dosFields = peInstance.dosHeader.getFields() print "[+] IMAGE_DOS_HEADER values:\n" for field in dosFields: if isinstance(dosFields[field], datatypes.Array): print "--> %s - Array of length %d" % (field,...
python
def showDosHeaderData(peInstance): """ Prints IMAGE_DOS_HEADER fields. """ dosFields = peInstance.dosHeader.getFields() print "[+] IMAGE_DOS_HEADER values:\n" for field in dosFields: if isinstance(dosFields[field], datatypes.Array): print "--> %s - Array of length %d" % (field,...
[ "def", "showDosHeaderData", "(", "peInstance", ")", ":", "dosFields", "=", "peInstance", ".", "dosHeader", ".", "getFields", "(", ")", "print", "\"[+] IMAGE_DOS_HEADER values:\\n\"", "for", "field", "in", "dosFields", ":", "if", "isinstance", "(", "dosFields", "["...
Prints IMAGE_DOS_HEADER fields.
[ "Prints", "IMAGE_DOS_HEADER", "fields", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/tools/readpe.py#L43-L56
crackinglandia/pype32
tools/readpe.py
showFileHeaderData
def showFileHeaderData(peInstance): """ Prints IMAGE_FILE_HEADER fields. """ fileHeaderFields = peInstance.ntHeaders.fileHeader.getFields() print "[+] IMAGE_FILE_HEADER values:\n" for field in fileHeaderFields: print "--> %s = 0x%08x" % (field, fileHeaderFields[field].value)
python
def showFileHeaderData(peInstance): """ Prints IMAGE_FILE_HEADER fields. """ fileHeaderFields = peInstance.ntHeaders.fileHeader.getFields() print "[+] IMAGE_FILE_HEADER values:\n" for field in fileHeaderFields: print "--> %s = 0x%08x" % (field, fileHeaderFields[field].value)
[ "def", "showFileHeaderData", "(", "peInstance", ")", ":", "fileHeaderFields", "=", "peInstance", ".", "ntHeaders", ".", "fileHeader", ".", "getFields", "(", ")", "print", "\"[+] IMAGE_FILE_HEADER values:\\n\"", "for", "field", "in", "fileHeaderFields", ":", "print", ...
Prints IMAGE_FILE_HEADER fields.
[ "Prints", "IMAGE_FILE_HEADER", "fields", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/tools/readpe.py#L64-L70
crackinglandia/pype32
tools/readpe.py
showOptionalHeaderData
def showOptionalHeaderData(peInstance): """ Prints IMAGE_OPTIONAL_HEADER fields. """ print "[+] IMAGE_OPTIONAL_HEADER:\n" ohFields = peInstance.ntHeaders.optionalHeader.getFields() for field in ohFields: if not isinstance(ohFields[field], datadirs.DataDirectory): print "--> %s ...
python
def showOptionalHeaderData(peInstance): """ Prints IMAGE_OPTIONAL_HEADER fields. """ print "[+] IMAGE_OPTIONAL_HEADER:\n" ohFields = peInstance.ntHeaders.optionalHeader.getFields() for field in ohFields: if not isinstance(ohFields[field], datadirs.DataDirectory): print "--> %s ...
[ "def", "showOptionalHeaderData", "(", "peInstance", ")", ":", "print", "\"[+] IMAGE_OPTIONAL_HEADER:\\n\"", "ohFields", "=", "peInstance", ".", "ntHeaders", ".", "optionalHeader", ".", "getFields", "(", ")", "for", "field", "in", "ohFields", ":", "if", "not", "isi...
Prints IMAGE_OPTIONAL_HEADER fields.
[ "Prints", "IMAGE_OPTIONAL_HEADER", "fields", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/tools/readpe.py#L72-L79
crackinglandia/pype32
tools/readpe.py
showDataDirectoriesData
def showDataDirectoriesData(peInstance): """ Prints the DATA_DIRECTORY fields. """ print "[+] Data directories:\n" dirs = peInstance.ntHeaders.optionalHeader.dataDirectory counter = 1 for dir in dirs: print "[%d] --> Name: %s -- RVA: 0x%08x -- SIZE: 0x%08x" % (counter, dir.name.value, ...
python
def showDataDirectoriesData(peInstance): """ Prints the DATA_DIRECTORY fields. """ print "[+] Data directories:\n" dirs = peInstance.ntHeaders.optionalHeader.dataDirectory counter = 1 for dir in dirs: print "[%d] --> Name: %s -- RVA: 0x%08x -- SIZE: 0x%08x" % (counter, dir.name.value, ...
[ "def", "showDataDirectoriesData", "(", "peInstance", ")", ":", "print", "\"[+] Data directories:\\n\"", "dirs", "=", "peInstance", ".", "ntHeaders", ".", "optionalHeader", ".", "dataDirectory", "counter", "=", "1", "for", "dir", "in", "dirs", ":", "print", "\"[%d]...
Prints the DATA_DIRECTORY fields.
[ "Prints", "the", "DATA_DIRECTORY", "fields", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/tools/readpe.py#L81-L89
crackinglandia/pype32
tools/readpe.py
showSectionsHeaders
def showSectionsHeaders(peInstance): """ Prints IMAGE_SECTION_HEADER for every section present in the file. """ print "[+] Sections information:\n" print "--> NumberOfSections: %d\n" % peInstance.ntHeaders.fileHeader.numberOfSections.value for section in peInstance.sectionHeaders: fields = ...
python
def showSectionsHeaders(peInstance): """ Prints IMAGE_SECTION_HEADER for every section present in the file. """ print "[+] Sections information:\n" print "--> NumberOfSections: %d\n" % peInstance.ntHeaders.fileHeader.numberOfSections.value for section in peInstance.sectionHeaders: fields = ...
[ "def", "showSectionsHeaders", "(", "peInstance", ")", ":", "print", "\"[+] Sections information:\\n\"", "print", "\"--> NumberOfSections: %d\\n\"", "%", "peInstance", ".", "ntHeaders", ".", "fileHeader", ".", "numberOfSections", ".", "value", "for", "section", "in", "pe...
Prints IMAGE_SECTION_HEADER for every section present in the file.
[ "Prints", "IMAGE_SECTION_HEADER", "for", "every", "section", "present", "in", "the", "file", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/tools/readpe.py#L91-L104
crackinglandia/pype32
tools/readpe.py
showImports
def showImports(peInstance): """ Shows imports information. """ iidEntries = peInstance.ntHeaders.optionalHeader.dataDirectory[consts.IMPORT_DIRECTORY].info if iidEntries: for iidEntry in iidEntries: fields = iidEntry.getFields() print "module: %s" % iidEntry.metaData.mo...
python
def showImports(peInstance): """ Shows imports information. """ iidEntries = peInstance.ntHeaders.optionalHeader.dataDirectory[consts.IMPORT_DIRECTORY].info if iidEntries: for iidEntry in iidEntries: fields = iidEntry.getFields() print "module: %s" % iidEntry.metaData.mo...
[ "def", "showImports", "(", "peInstance", ")", ":", "iidEntries", "=", "peInstance", ".", "ntHeaders", ".", "optionalHeader", ".", "dataDirectory", "[", "consts", ".", "IMPORT_DIRECTORY", "]", ".", "info", "if", "iidEntries", ":", "for", "iidEntry", "in", "iidE...
Shows imports information.
[ "Shows", "imports", "information", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/tools/readpe.py#L106-L124
crackinglandia/pype32
tools/readpe.py
showExports
def showExports(peInstance): """ Show exports information """ exports = peInstance.ntHeaders.optionalHeader.dataDirectory[consts.EXPORT_DIRECTORY].info if exports: exp_fields = exports.getFields() for field in exp_fields: print "%s -> %x" % (field, exp_fields[field].value) ...
python
def showExports(peInstance): """ Show exports information """ exports = peInstance.ntHeaders.optionalHeader.dataDirectory[consts.EXPORT_DIRECTORY].info if exports: exp_fields = exports.getFields() for field in exp_fields: print "%s -> %x" % (field, exp_fields[field].value) ...
[ "def", "showExports", "(", "peInstance", ")", ":", "exports", "=", "peInstance", ".", "ntHeaders", ".", "optionalHeader", ".", "dataDirectory", "[", "consts", ".", "EXPORT_DIRECTORY", "]", ".", "info", "if", "exports", ":", "exp_fields", "=", "exports", ".", ...
Show exports information
[ "Show", "exports", "information" ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/tools/readpe.py#L126-L140
crackinglandia/pype32
pype32/baseclasses.py
BaseStructClass.getFields
def getFields(self): """ Returns all the class attributues. @rtype: dict @return: A dictionary containing all the class attributes. """ d = {} for i in self._attrsList: key = i value = getattr(self, i) d[key] = value ...
python
def getFields(self): """ Returns all the class attributues. @rtype: dict @return: A dictionary containing all the class attributes. """ d = {} for i in self._attrsList: key = i value = getattr(self, i) d[key] = value ...
[ "def", "getFields", "(", "self", ")", ":", "d", "=", "{", "}", "for", "i", "in", "self", ".", "_attrsList", ":", "key", "=", "i", "value", "=", "getattr", "(", "self", ",", "i", ")", "d", "[", "key", "]", "=", "value", "return", "d" ]
Returns all the class attributues. @rtype: dict @return: A dictionary containing all the class attributes.
[ "Returns", "all", "the", "class", "attributues", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/baseclasses.py#L65-L77
crackinglandia/pype32
pype32/datatypes.py
Array.parse
def parse(readDataInstance, arrayType, arrayLength): """ Returns a new L{Array} object. @type readDataInstance: L{ReadData} @param readDataInstance: The L{ReadData} object containing the array data. @type arrayType: int @param arrayType: The type of L{...
python
def parse(readDataInstance, arrayType, arrayLength): """ Returns a new L{Array} object. @type readDataInstance: L{ReadData} @param readDataInstance: The L{ReadData} object containing the array data. @type arrayType: int @param arrayType: The type of L{...
[ "def", "parse", "(", "readDataInstance", ",", "arrayType", ",", "arrayLength", ")", ":", "newArray", "=", "Array", "(", "arrayType", ")", "dataLength", "=", "len", "(", "readDataInstance", ")", "if", "arrayType", "is", "TYPE_DWORD", ":", "toRead", "=", "arra...
Returns a new L{Array} object. @type readDataInstance: L{ReadData} @param readDataInstance: The L{ReadData} object containing the array data. @type arrayType: int @param arrayType: The type of L{Array} to be built. @type arrayLength: int @param ...
[ "Returns", "a", "new", "L", "{", "Array", "}", "object", "." ]
train
https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/datatypes.py#L145-L196
tansey/gfl
pygfl/trails.py
calc_euler_tour
def calc_euler_tour(g, start, end): '''Calculates an Euler tour over the graph g from vertex start to vertex end. Assumes start and end are odd-degree vertices and that there are no other odd-degree vertices.''' even_g = nx.subgraph(g, g.nodes()).copy() if end in even_g.neighbors(start): # I...
python
def calc_euler_tour(g, start, end): '''Calculates an Euler tour over the graph g from vertex start to vertex end. Assumes start and end are odd-degree vertices and that there are no other odd-degree vertices.''' even_g = nx.subgraph(g, g.nodes()).copy() if end in even_g.neighbors(start): # I...
[ "def", "calc_euler_tour", "(", "g", ",", "start", ",", "end", ")", ":", "even_g", "=", "nx", ".", "subgraph", "(", "g", ",", "g", ".", "nodes", "(", ")", ")", ".", "copy", "(", ")", "if", "end", "in", "even_g", ".", "neighbors", "(", "start", "...
Calculates an Euler tour over the graph g from vertex start to vertex end. Assumes start and end are odd-degree vertices and that there are no other odd-degree vertices.
[ "Calculates", "an", "Euler", "tour", "over", "the", "graph", "g", "from", "vertex", "start", "to", "vertex", "end", ".", "Assumes", "start", "and", "end", "are", "odd", "-", "degree", "vertices", "and", "that", "there", "are", "no", "other", "odd", "-", ...
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/trails.py#L50-L79
tansey/gfl
pygfl/trails.py
greedy_trails
def greedy_trails(subg, odds, verbose): '''Greedily select trails by making the longest you can until the end''' if verbose: print('\tCreating edge map') edges = defaultdict(list) for x,y in subg.edges(): edges[x].append(y) edges[y].append(x) if verbose: print('\tS...
python
def greedy_trails(subg, odds, verbose): '''Greedily select trails by making the longest you can until the end''' if verbose: print('\tCreating edge map') edges = defaultdict(list) for x,y in subg.edges(): edges[x].append(y) edges[y].append(x) if verbose: print('\tS...
[ "def", "greedy_trails", "(", "subg", ",", "odds", ",", "verbose", ")", ":", "if", "verbose", ":", "print", "(", "'\\tCreating edge map'", ")", "edges", "=", "defaultdict", "(", "list", ")", "for", "x", ",", "y", "in", "subg", ".", "edges", "(", ")", ...
Greedily select trails by making the longest you can until the end
[ "Greedily", "select", "trails", "by", "making", "the", "longest", "you", "can", "until", "the", "end" ]
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/trails.py#L307-L338
tansey/gfl
pygfl/trails.py
decompose_graph
def decompose_graph(g, heuristic='tour', max_odds=20, verbose=0): '''Decompose a graph into a set of non-overlapping trails.''' # Get the connected subgraphs subgraphs = [nx.subgraph(g, x).copy() for x in nx.connected_components(g)] chains = [] num_subgraphs = len(subgraphs) step = 0 while ...
python
def decompose_graph(g, heuristic='tour', max_odds=20, verbose=0): '''Decompose a graph into a set of non-overlapping trails.''' # Get the connected subgraphs subgraphs = [nx.subgraph(g, x).copy() for x in nx.connected_components(g)] chains = [] num_subgraphs = len(subgraphs) step = 0 while ...
[ "def", "decompose_graph", "(", "g", ",", "heuristic", "=", "'tour'", ",", "max_odds", "=", "20", ",", "verbose", "=", "0", ")", ":", "# Get the connected subgraphs", "subgraphs", "=", "[", "nx", ".", "subgraph", "(", "g", ",", "x", ")", ".", "copy", "(...
Decompose a graph into a set of non-overlapping trails.
[ "Decompose", "a", "graph", "into", "a", "set", "of", "non", "-", "overlapping", "trails", "." ]
train
https://github.com/tansey/gfl/blob/ae0f078bab57aba9e827ed6162f247ff9dc2aa19/pygfl/trails.py#L341-L414
timknip/pycsg
csg/geom.py
Vector.plus
def plus(self, a): """ Add. """ return Vector(self.x+a.x, self.y+a.y, self.z+a.z)
python
def plus(self, a): """ Add. """ return Vector(self.x+a.x, self.y+a.y, self.z+a.z)
[ "def", "plus", "(", "self", ",", "a", ")", ":", "return", "Vector", "(", "self", ".", "x", "+", "a", ".", "x", ",", "self", ".", "y", "+", "a", ".", "y", ",", "self", ".", "z", "+", "a", ".", "z", ")" ]
Add.
[ "Add", "." ]
train
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/geom.py#L50-L52
timknip/pycsg
csg/geom.py
Vector.minus
def minus(self, a): """ Subtract. """ return Vector(self.x-a.x, self.y-a.y, self.z-a.z)
python
def minus(self, a): """ Subtract. """ return Vector(self.x-a.x, self.y-a.y, self.z-a.z)
[ "def", "minus", "(", "self", ",", "a", ")", ":", "return", "Vector", "(", "self", ".", "x", "-", "a", ".", "x", ",", "self", ".", "y", "-", "a", ".", "y", ",", "self", ".", "z", "-", "a", ".", "z", ")" ]
Subtract.
[ "Subtract", "." ]
train
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/geom.py#L57-L59
timknip/pycsg
csg/geom.py
Vector.times
def times(self, a): """ Multiply. """ return Vector(self.x*a, self.y*a, self.z*a)
python
def times(self, a): """ Multiply. """ return Vector(self.x*a, self.y*a, self.z*a)
[ "def", "times", "(", "self", ",", "a", ")", ":", "return", "Vector", "(", "self", ".", "x", "*", "a", ",", "self", ".", "y", "*", "a", ",", "self", ".", "z", "*", "a", ")" ]
Multiply.
[ "Multiply", "." ]
train
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/geom.py#L64-L66
timknip/pycsg
csg/geom.py
Vector.dividedBy
def dividedBy(self, a): """ Divide. """ return Vector(self.x/a, self.y/a, self.z/a)
python
def dividedBy(self, a): """ Divide. """ return Vector(self.x/a, self.y/a, self.z/a)
[ "def", "dividedBy", "(", "self", ",", "a", ")", ":", "return", "Vector", "(", "self", ".", "x", "/", "a", ",", "self", ".", "y", "/", "a", ",", "self", ".", "z", "/", "a", ")" ]
Divide.
[ "Divide", "." ]
train
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/geom.py#L71-L73
timknip/pycsg
csg/geom.py
Vector.lerp
def lerp(self, a, t): """ Lerp. Linear interpolation from self to a""" return self.plus(a.minus(self).times(t));
python
def lerp(self, a, t): """ Lerp. Linear interpolation from self to a""" return self.plus(a.minus(self).times(t));
[ "def", "lerp", "(", "self", ",", "a", ",", "t", ")", ":", "return", "self", ".", "plus", "(", "a", ".", "minus", "(", "self", ")", ".", "times", "(", "t", ")", ")" ]
Lerp. Linear interpolation from self to a
[ "Lerp", ".", "Linear", "interpolation", "from", "self", "to", "a" ]
train
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/geom.py#L85-L87
timknip/pycsg
csg/geom.py
Vertex.interpolate
def interpolate(self, other, t): """ Create a new vertex between this vertex and `other` by linearly interpolating all properties using a parameter of `t`. Subclasses should override this to interpolate additional properties. """ return Vertex(self.pos.lerp(other.pos, t),...
python
def interpolate(self, other, t): """ Create a new vertex between this vertex and `other` by linearly interpolating all properties using a parameter of `t`. Subclasses should override this to interpolate additional properties. """ return Vertex(self.pos.lerp(other.pos, t),...
[ "def", "interpolate", "(", "self", ",", "other", ",", "t", ")", ":", "return", "Vertex", "(", "self", ".", "pos", ".", "lerp", "(", "other", ".", "pos", ",", "t", ")", ",", "self", ".", "normal", ".", "lerp", "(", "other", ".", "normal", ",", "...
Create a new vertex between this vertex and `other` by linearly interpolating all properties using a parameter of `t`. Subclasses should override this to interpolate additional properties.
[ "Create", "a", "new", "vertex", "between", "this", "vertex", "and", "other", "by", "linearly", "interpolating", "all", "properties", "using", "a", "parameter", "of", "t", ".", "Subclasses", "should", "override", "this", "to", "interpolate", "additional", "proper...
train
https://github.com/timknip/pycsg/blob/b8f9710fd15c38dcc275d56a2108f604af38dcc8/csg/geom.py#L147-L154