repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
allianceauth/allianceauth
allianceauth/timerboard/views.py
AddUpdateMixin.get_form_kwargs
def get_form_kwargs(self): """ Inject the request user into the kwargs passed to the form """ kwargs = super(AddUpdateMixin, self).get_form_kwargs() kwargs.update({'user': self.request.user}) return kwargs
python
def get_form_kwargs(self): """ Inject the request user into the kwargs passed to the form """ kwargs = super(AddUpdateMixin, self).get_form_kwargs() kwargs.update({'user': self.request.user}) return kwargs
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", "AddUpdateMixin", ",", "self", ")", ".", "get_form_kwargs", "(", ")", "kwargs", ".", "update", "(", "{", "'user'", ":", "self", ".", "request", ".", "user", "}", ")", "return...
Inject the request user into the kwargs passed to the form
[ "Inject", "the", "request", "user", "into", "the", "kwargs", "passed", "to", "the", "form" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/timerboard/views.py#L58-L64
train
allianceauth/allianceauth
allianceauth/services/abstract.py
ServicesCRUDMixin.get_object
def get_object(self, queryset=None): """ Returns the object the view is displaying. """ if queryset is None: queryset = self.get_queryset() try: return queryset.get(user__pk=self.request.user.pk) except ObjectDoesNotExist: raise Http40...
python
def get_object(self, queryset=None): """ Returns the object the view is displaying. """ if queryset is None: queryset = self.get_queryset() try: return queryset.get(user__pk=self.request.user.pk) except ObjectDoesNotExist: raise Http40...
[ "def", "get_object", "(", "self", ",", "queryset", "=", "None", ")", ":", "if", "queryset", "is", "None", ":", "queryset", "=", "self", ".", "get_queryset", "(", ")", "try", ":", "return", "queryset", ".", "get", "(", "user__pk", "=", "self", ".", "r...
Returns the object the view is displaying.
[ "Returns", "the", "object", "the", "view", "is", "displaying", "." ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/abstract.py#L79-L89
train
allianceauth/allianceauth
allianceauth/groupmanagement/managers.py
GroupManager.can_manage_groups
def can_manage_groups(cls, user): """ For use with user_passes_test decorator. Check if the user can manage groups. Either has the auth.group_management permission or is a leader of at least one group and is also a Member. :param user: django.contrib.auth.models.User for ...
python
def can_manage_groups(cls, user): """ For use with user_passes_test decorator. Check if the user can manage groups. Either has the auth.group_management permission or is a leader of at least one group and is also a Member. :param user: django.contrib.auth.models.User for ...
[ "def", "can_manage_groups", "(", "cls", ",", "user", ")", ":", "if", "user", ".", "is_authenticated", ":", "return", "cls", ".", "has_management_permission", "(", "user", ")", "or", "user", ".", "leads_groups", ".", "all", "(", ")", "return", "False" ]
For use with user_passes_test decorator. Check if the user can manage groups. Either has the auth.group_management permission or is a leader of at least one group and is also a Member. :param user: django.contrib.auth.models.User for the request :return: bool True if user can man...
[ "For", "use", "with", "user_passes_test", "decorator", ".", "Check", "if", "the", "user", "can", "manage", "groups", ".", "Either", "has", "the", "auth", ".", "group_management", "permission", "or", "is", "a", "leader", "of", "at", "least", "one", "group", ...
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/groupmanagement/managers.py#L31-L42
train
allianceauth/allianceauth
allianceauth/groupmanagement/managers.py
GroupManager.can_manage_group
def can_manage_group(cls, user, group): """ Check user has permission to manage the given group :param user: User object to test permission of :param group: Group object the user is attempting to manage :return: True if the user can manage the group """ if user.is...
python
def can_manage_group(cls, user, group): """ Check user has permission to manage the given group :param user: User object to test permission of :param group: Group object the user is attempting to manage :return: True if the user can manage the group """ if user.is...
[ "def", "can_manage_group", "(", "cls", ",", "user", ",", "group", ")", ":", "if", "user", ".", "is_authenticated", ":", "return", "cls", ".", "has_management_permission", "(", "user", ")", "or", "user", ".", "leads_groups", ".", "filter", "(", "group", "="...
Check user has permission to manage the given group :param user: User object to test permission of :param group: Group object the user is attempting to manage :return: True if the user can manage the group
[ "Check", "user", "has", "permission", "to", "manage", "the", "given", "group", ":", "param", "user", ":", "User", "object", "to", "test", "permission", "of", ":", "param", "group", ":", "Group", "object", "the", "user", "is", "attempting", "to", "manage", ...
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/groupmanagement/managers.py#L45-L54
train
allianceauth/allianceauth
allianceauth/groupmanagement/models.py
create_auth_group
def create_auth_group(sender, instance, created, **kwargs): """ Creates the AuthGroup model when a group is created """ if created: AuthGroup.objects.create(group=instance)
python
def create_auth_group(sender, instance, created, **kwargs): """ Creates the AuthGroup model when a group is created """ if created: AuthGroup.objects.create(group=instance)
[ "def", "create_auth_group", "(", "sender", ",", "instance", ",", "created", ",", "*", "*", "kwargs", ")", ":", "if", "created", ":", "AuthGroup", ".", "objects", ".", "create", "(", "group", "=", "instance", ")" ]
Creates the AuthGroup model when a group is created
[ "Creates", "the", "AuthGroup", "model", "when", "a", "group", "is", "created" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/groupmanagement/models.py#L81-L86
train
allianceauth/allianceauth
allianceauth/services/modules/teamspeak3/util/ts3.py
TS3Proto.construct_command
def construct_command(self, command, keys=None, opts=None): """ Constructs a TS3 formatted command string Keys can have a single nested list to construct a nested parameter @param command: Command list @type command: string @param keys: Key/Value pairs @type keys:...
python
def construct_command(self, command, keys=None, opts=None): """ Constructs a TS3 formatted command string Keys can have a single nested list to construct a nested parameter @param command: Command list @type command: string @param keys: Key/Value pairs @type keys:...
[ "def", "construct_command", "(", "self", ",", "command", ",", "keys", "=", "None", ",", "opts", "=", "None", ")", ":", "cstr", "=", "[", "command", "]", "# Add the keys and values, escape as needed", "if", "keys", ":", "for", "key", "in", "keys", ":", "if"...
Constructs a TS3 formatted command string Keys can have a single nested list to construct a nested parameter @param command: Command list @type command: string @param keys: Key/Value pairs @type keys: dict @param opts: Options @type opts: list
[ "Constructs", "a", "TS3", "formatted", "command", "string", "Keys", "can", "have", "a", "single", "nested", "list", "to", "construct", "a", "nested", "parameter" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/teamspeak3/util/ts3.py#L103-L133
train
allianceauth/allianceauth
allianceauth/services/modules/teamspeak3/util/ts3.py
TS3Proto.parse_command
def parse_command(self, commandstr): """ Parses a TS3 command string into command/keys/opts tuple @param commandstr: Command string @type commandstr: string """ if len(commandstr.split('|')) > 1: vals = [] for cmd in commandstr.split('|'): ...
python
def parse_command(self, commandstr): """ Parses a TS3 command string into command/keys/opts tuple @param commandstr: Command string @type commandstr: string """ if len(commandstr.split('|')) > 1: vals = [] for cmd in commandstr.split('|'): ...
[ "def", "parse_command", "(", "self", ",", "commandstr", ")", ":", "if", "len", "(", "commandstr", ".", "split", "(", "'|'", ")", ")", ">", "1", ":", "vals", "=", "[", "]", "for", "cmd", "in", "commandstr", ".", "split", "(", "'|'", ")", ":", "val...
Parses a TS3 command string into command/keys/opts tuple @param commandstr: Command string @type commandstr: string
[ "Parses", "a", "TS3", "command", "string", "into", "command", "/", "keys", "/", "opts", "tuple" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/teamspeak3/util/ts3.py#L135-L172
train
allianceauth/allianceauth
allianceauth/services/modules/teamspeak3/util/ts3.py
TS3Proto._escape_str
def _escape_str(value): """ Escape a value into a TS3 compatible string @param value: Value @type value: string/int """ if isinstance(value, int): return "%d" % value value = value.replace("\\", r'\\') for i, j in ts3_escape.items(): ...
python
def _escape_str(value): """ Escape a value into a TS3 compatible string @param value: Value @type value: string/int """ if isinstance(value, int): return "%d" % value value = value.replace("\\", r'\\') for i, j in ts3_escape.items(): ...
[ "def", "_escape_str", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "int", ")", ":", "return", "\"%d\"", "%", "value", "value", "=", "value", ".", "replace", "(", "\"\\\\\"", ",", "r'\\\\'", ")", "for", "i", ",", "j", "in", "ts3_esca...
Escape a value into a TS3 compatible string @param value: Value @type value: string/int
[ "Escape", "a", "value", "into", "a", "TS3", "compatible", "string" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/teamspeak3/util/ts3.py#L175-L187
train
allianceauth/allianceauth
allianceauth/services/modules/teamspeak3/util/ts3.py
TS3Proto._unescape_str
def _unescape_str(value): """ Unescape a TS3 compatible string into a normal string @param value: Value @type value: string/int """ if isinstance(value, int): return "%d" % value value = value.replace(r"\\", "\\") for i, j in ts3_escape.items(...
python
def _unescape_str(value): """ Unescape a TS3 compatible string into a normal string @param value: Value @type value: string/int """ if isinstance(value, int): return "%d" % value value = value.replace(r"\\", "\\") for i, j in ts3_escape.items(...
[ "def", "_unescape_str", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "int", ")", ":", "return", "\"%d\"", "%", "value", "value", "=", "value", ".", "replace", "(", "r\"\\\\\"", ",", "\"\\\\\"", ")", "for", "i", ",", "j", "in", "ts3_...
Unescape a TS3 compatible string into a normal string @param value: Value @type value: string/int
[ "Unescape", "a", "TS3", "compatible", "string", "into", "a", "normal", "string" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/teamspeak3/util/ts3.py#L190-L202
train
allianceauth/allianceauth
allianceauth/services/modules/teamspeak3/util/ts3.py
TS3Server.login
def login(self, username, password): """ Login to the TS3 Server @param username: Username @type username: str @param password: Password @type password: str """ d = self.send_command('login', keys={'client_login_name': username, 'client_login_password': pa...
python
def login(self, username, password): """ Login to the TS3 Server @param username: Username @type username: str @param password: Password @type password: str """ d = self.send_command('login', keys={'client_login_name': username, 'client_login_password': pa...
[ "def", "login", "(", "self", ",", "username", ",", "password", ")", ":", "d", "=", "self", ".", "send_command", "(", "'login'", ",", "keys", "=", "{", "'client_login_name'", ":", "username", ",", "'client_login_password'", ":", "password", "}", ")", "if", ...
Login to the TS3 Server @param username: Username @type username: str @param password: Password @type password: str
[ "Login", "to", "the", "TS3", "Server" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/teamspeak3/util/ts3.py#L223-L235
train
allianceauth/allianceauth
allianceauth/services/modules/teamspeak3/util/ts3.py
TS3Server.use
def use(self, id): """ Use a particular Virtual Server instance @param id: Virtual Server ID @type id: int """ if self._connected and id > 0: self.send_command('use', keys={'sid': id})
python
def use(self, id): """ Use a particular Virtual Server instance @param id: Virtual Server ID @type id: int """ if self._connected and id > 0: self.send_command('use', keys={'sid': id})
[ "def", "use", "(", "self", ",", "id", ")", ":", "if", "self", ".", "_connected", "and", "id", ">", "0", ":", "self", ".", "send_command", "(", "'use'", ",", "keys", "=", "{", "'sid'", ":", "id", "}", ")" ]
Use a particular Virtual Server instance @param id: Virtual Server ID @type id: int
[ "Use", "a", "particular", "Virtual", "Server", "instance" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/teamspeak3/util/ts3.py#L253-L260
train
allianceauth/allianceauth
allianceauth/services/modules/example/auth_hooks.py
ExampleService.render_services_ctrl
def render_services_ctrl(self, request): """ Example for rendering the service control panel row You can override the default template and create a custom one if you wish. :param request: :return: """ urls = self.Urls() urls.auth_activate = 'auth_e...
python
def render_services_ctrl(self, request): """ Example for rendering the service control panel row You can override the default template and create a custom one if you wish. :param request: :return: """ urls = self.Urls() urls.auth_activate = 'auth_e...
[ "def", "render_services_ctrl", "(", "self", ",", "request", ")", ":", "urls", "=", "self", ".", "Urls", "(", ")", "urls", ".", "auth_activate", "=", "'auth_example_activate'", "urls", ".", "auth_deactivate", "=", "'auth_example_deactivate'", "urls", ".", "auth_r...
Example for rendering the service control panel row You can override the default template and create a custom one if you wish. :param request: :return:
[ "Example", "for", "rendering", "the", "service", "control", "panel", "row", "You", "can", "override", "the", "default", "template", "and", "create", "a", "custom", "one", "if", "you", "wish", ".", ":", "param", "request", ":", ":", "return", ":" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/example/auth_hooks.py#L19-L37
train
allianceauth/allianceauth
allianceauth/eveonline/models.py
EveCharacter.alliance
def alliance(self) -> Union[EveAllianceInfo, None]: """ Pseudo foreign key from alliance_id to EveAllianceInfo :raises: EveAllianceInfo.DoesNotExist :return: EveAllianceInfo or None """ if self.alliance_id is None: return None return EveAllianceInfo.ob...
python
def alliance(self) -> Union[EveAllianceInfo, None]: """ Pseudo foreign key from alliance_id to EveAllianceInfo :raises: EveAllianceInfo.DoesNotExist :return: EveAllianceInfo or None """ if self.alliance_id is None: return None return EveAllianceInfo.ob...
[ "def", "alliance", "(", "self", ")", "->", "Union", "[", "EveAllianceInfo", ",", "None", "]", ":", "if", "self", ".", "alliance_id", "is", "None", ":", "return", "None", "return", "EveAllianceInfo", ".", "objects", ".", "get", "(", "alliance_id", "=", "s...
Pseudo foreign key from alliance_id to EveAllianceInfo :raises: EveAllianceInfo.DoesNotExist :return: EveAllianceInfo or None
[ "Pseudo", "foreign", "key", "from", "alliance_id", "to", "EveAllianceInfo", ":", "raises", ":", "EveAllianceInfo", ".", "DoesNotExist", ":", "return", ":", "EveAllianceInfo", "or", "None" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/models.py#L96-L104
train
allianceauth/allianceauth
allianceauth/eveonline/autogroups/signals.py
pre_save_config
def pre_save_config(sender, instance, *args, **kwargs): """ Checks if enable was toggled on group config and deletes groups if necessary. """ logger.debug("Received pre_save from {}".format(instance)) if not instance.pk: # new model being created return try: old_insta...
python
def pre_save_config(sender, instance, *args, **kwargs): """ Checks if enable was toggled on group config and deletes groups if necessary. """ logger.debug("Received pre_save from {}".format(instance)) if not instance.pk: # new model being created return try: old_insta...
[ "def", "pre_save_config", "(", "sender", ",", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "\"Received pre_save from {}\"", ".", "format", "(", "instance", ")", ")", "if", "not", "instance", ".", "pk", ":"...
Checks if enable was toggled on group config and deletes groups if necessary.
[ "Checks", "if", "enable", "was", "toggled", "on", "group", "config", "and", "deletes", "groups", "if", "necessary", "." ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/autogroups/signals.py#L13-L32
train
allianceauth/allianceauth
allianceauth/eveonline/autogroups/signals.py
check_groups_on_profile_update
def check_groups_on_profile_update(sender, instance, created, *args, **kwargs): """ Trigger check when main character or state changes. """ AutogroupsConfig.objects.update_groups_for_user(instance.user)
python
def check_groups_on_profile_update(sender, instance, created, *args, **kwargs): """ Trigger check when main character or state changes. """ AutogroupsConfig.objects.update_groups_for_user(instance.user)
[ "def", "check_groups_on_profile_update", "(", "sender", ",", "instance", ",", "created", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "AutogroupsConfig", ".", "objects", ".", "update_groups_for_user", "(", "instance", ".", "user", ")" ]
Trigger check when main character or state changes.
[ "Trigger", "check", "when", "main", "character", "or", "state", "changes", "." ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/autogroups/signals.py#L45-L49
train
allianceauth/allianceauth
allianceauth/eveonline/autogroups/signals.py
autogroups_states_changed
def autogroups_states_changed(sender, instance, action, reverse, model, pk_set, *args, **kwargs): """ Trigger group membership update when a state is added or removed from an autogroup config. """ if action.startswith('post_'): for pk in pk_set: try: state = State...
python
def autogroups_states_changed(sender, instance, action, reverse, model, pk_set, *args, **kwargs): """ Trigger group membership update when a state is added or removed from an autogroup config. """ if action.startswith('post_'): for pk in pk_set: try: state = State...
[ "def", "autogroups_states_changed", "(", "sender", ",", "instance", ",", "action", ",", "reverse", ",", "model", ",", "pk_set", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "action", ".", "startswith", "(", "'post_'", ")", ":", "for", "pk...
Trigger group membership update when a state is added or removed from an autogroup config.
[ "Trigger", "group", "membership", "update", "when", "a", "state", "is", "added", "or", "removed", "from", "an", "autogroup", "config", "." ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/autogroups/signals.py#L53-L65
train
allianceauth/allianceauth
allianceauth/authentication/admin.py
make_service_hooks_update_groups_action
def make_service_hooks_update_groups_action(service): """ Make a admin action for the given service :param service: services.hooks.ServicesHook :return: fn to update services groups for the selected users """ def update_service_groups(modeladmin, request, queryset): for user in queryset:...
python
def make_service_hooks_update_groups_action(service): """ Make a admin action for the given service :param service: services.hooks.ServicesHook :return: fn to update services groups for the selected users """ def update_service_groups(modeladmin, request, queryset): for user in queryset:...
[ "def", "make_service_hooks_update_groups_action", "(", "service", ")", ":", "def", "update_service_groups", "(", "modeladmin", ",", "request", ",", "queryset", ")", ":", "for", "user", "in", "queryset", ":", "# queryset filtering doesn't work here?", "service", ".", "...
Make a admin action for the given service :param service: services.hooks.ServicesHook :return: fn to update services groups for the selected users
[ "Make", "a", "admin", "action", "for", "the", "given", "service", ":", "param", "service", ":", "services", ".", "hooks", ".", "ServicesHook", ":", "return", ":", "fn", "to", "update", "services", "groups", "for", "the", "selected", "users" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/authentication/admin.py#L15-L27
train
allianceauth/allianceauth
allianceauth/authentication/admin.py
make_service_hooks_sync_nickname_action
def make_service_hooks_sync_nickname_action(service): """ Make a sync_nickname admin action for the given service :param service: services.hooks.ServicesHook :return: fn to sync nickname for the selected users """ def sync_nickname(modeladmin, request, queryset): for user in queryset: #...
python
def make_service_hooks_sync_nickname_action(service): """ Make a sync_nickname admin action for the given service :param service: services.hooks.ServicesHook :return: fn to sync nickname for the selected users """ def sync_nickname(modeladmin, request, queryset): for user in queryset: #...
[ "def", "make_service_hooks_sync_nickname_action", "(", "service", ")", ":", "def", "sync_nickname", "(", "modeladmin", ",", "request", ",", "queryset", ")", ":", "for", "user", "in", "queryset", ":", "# queryset filtering doesn't work here?", "service", ".", "sync_nic...
Make a sync_nickname admin action for the given service :param service: services.hooks.ServicesHook :return: fn to sync nickname for the selected users
[ "Make", "a", "sync_nickname", "admin", "action", "for", "the", "given", "service", ":", "param", "service", ":", "services", ".", "hooks", ".", "ServicesHook", ":", "return", ":", "fn", "to", "sync", "nickname", "for", "the", "selected", "users" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/authentication/admin.py#L30-L42
train
allianceauth/allianceauth
allianceauth/thirdparty/navhelper/templatetags/navactive.py
renavactive
def renavactive(request, pattern): """ {% renavactive request "^/a_regex" %} """ if re.search(pattern, request.path): return getattr(settings, "NAVHELPER_ACTIVE_CLASS", "active") return getattr(settings, "NAVHELPER_NOT_ACTIVE_CLASS", "")
python
def renavactive(request, pattern): """ {% renavactive request "^/a_regex" %} """ if re.search(pattern, request.path): return getattr(settings, "NAVHELPER_ACTIVE_CLASS", "active") return getattr(settings, "NAVHELPER_NOT_ACTIVE_CLASS", "")
[ "def", "renavactive", "(", "request", ",", "pattern", ")", ":", "if", "re", ".", "search", "(", "pattern", ",", "request", ".", "path", ")", ":", "return", "getattr", "(", "settings", ",", "\"NAVHELPER_ACTIVE_CLASS\"", ",", "\"active\"", ")", "return", "ge...
{% renavactive request "^/a_regex" %}
[ "{", "%", "renavactive", "request", "^", "/", "a_regex", "%", "}" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/thirdparty/navhelper/templatetags/navactive.py#L33-L39
train
allianceauth/allianceauth
allianceauth/thirdparty/navhelper/templatetags/navactive.py
navactive
def navactive(request, urls): """ {% navactive request "view_name another_view_name" %} """ url_list = set(urls.split()) resolved = resolve(request.path) resolved_urls = set() if resolved.url_name: resolved_urls.add(resolved.url_name) if resolved.namespaces: resolved_url...
python
def navactive(request, urls): """ {% navactive request "view_name another_view_name" %} """ url_list = set(urls.split()) resolved = resolve(request.path) resolved_urls = set() if resolved.url_name: resolved_urls.add(resolved.url_name) if resolved.namespaces: resolved_url...
[ "def", "navactive", "(", "request", ",", "urls", ")", ":", "url_list", "=", "set", "(", "urls", ".", "split", "(", ")", ")", "resolved", "=", "resolve", "(", "request", ".", "path", ")", "resolved_urls", "=", "set", "(", ")", "if", "resolved", ".", ...
{% navactive request "view_name another_view_name" %}
[ "{", "%", "navactive", "request", "view_name", "another_view_name", "%", "}" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/thirdparty/navhelper/templatetags/navactive.py#L43-L63
train
allianceauth/allianceauth
allianceauth/eveonline/autogroups/models.py
AutogroupsConfigManager.update_groups_for_state
def update_groups_for_state(self, state: State): """ Update all the Group memberships for the users who have State :param state: State to update for :return: """ users = get_users_for_state(state) for config in self.filter(states=state): logger...
python
def update_groups_for_state(self, state: State): """ Update all the Group memberships for the users who have State :param state: State to update for :return: """ users = get_users_for_state(state) for config in self.filter(states=state): logger...
[ "def", "update_groups_for_state", "(", "self", ",", "state", ":", "State", ")", ":", "users", "=", "get_users_for_state", "(", "state", ")", "for", "config", "in", "self", ".", "filter", "(", "states", "=", "state", ")", ":", "logger", ".", "debug", "(",...
Update all the Group memberships for the users who have State :param state: State to update for :return:
[ "Update", "all", "the", "Group", "memberships", "for", "the", "users", "who", "have", "State", ":", "param", "state", ":", "State", "to", "update", "for", ":", "return", ":" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/autogroups/models.py#L18-L30
train
allianceauth/allianceauth
allianceauth/eveonline/autogroups/models.py
AutogroupsConfigManager.update_groups_for_user
def update_groups_for_user(self, user: User, state: State = None): """ Update the Group memberships for the given users state :param user: User to update for :param state: State to update user for :return: """ if state is None: state = user.profile.sta...
python
def update_groups_for_user(self, user: User, state: State = None): """ Update the Group memberships for the given users state :param user: User to update for :param state: State to update user for :return: """ if state is None: state = user.profile.sta...
[ "def", "update_groups_for_user", "(", "self", ",", "user", ":", "User", ",", "state", ":", "State", "=", "None", ")", ":", "if", "state", "is", "None", ":", "state", "=", "user", ".", "profile", ".", "state", "for", "config", "in", "self", ".", "filt...
Update the Group memberships for the given users state :param user: User to update for :param state: State to update user for :return:
[ "Update", "the", "Group", "memberships", "for", "the", "given", "users", "state", ":", "param", "user", ":", "User", "to", "update", "for", ":", "param", "state", ":", "State", "to", "update", "user", "for", ":", "return", ":" ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/autogroups/models.py#L32-L47
train
allianceauth/allianceauth
allianceauth/eveonline/autogroups/models.py
AutogroupsConfig._replace_spaces
def _replace_spaces(self, name: str) -> str: """ Replace the spaces in the given name based on the config :param name: name to replace spaces in :return: name with spaces replaced with the configured character(s) or unchanged if configured """ if self.replace_spaces: ...
python
def _replace_spaces(self, name: str) -> str: """ Replace the spaces in the given name based on the config :param name: name to replace spaces in :return: name with spaces replaced with the configured character(s) or unchanged if configured """ if self.replace_spaces: ...
[ "def", "_replace_spaces", "(", "self", ",", "name", ":", "str", ")", "->", "str", ":", "if", "self", ".", "replace_spaces", ":", "return", "name", ".", "strip", "(", ")", ".", "replace", "(", "' '", ",", "str", "(", "self", ".", "replace_spaces_with", ...
Replace the spaces in the given name based on the config :param name: name to replace spaces in :return: name with spaces replaced with the configured character(s) or unchanged if configured
[ "Replace", "the", "spaces", "in", "the", "given", "name", "based", "on", "the", "config", ":", "param", "name", ":", "name", "to", "replace", "spaces", "in", ":", "return", ":", "name", "with", "spaces", "replaced", "with", "the", "configured", "character"...
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/eveonline/autogroups/models.py#L225-L233
train
allianceauth/allianceauth
allianceauth/services/modules/discord/manager.py
api_backoff
def api_backoff(func): """ Decorator, Handles HTTP 429 "Too Many Requests" messages from the Discord API If blocking=True is specified, this function will block and retry the function up to max_retries=n times, or 3 if retries is not specified. If the API call still recieves a backoff timer this fun...
python
def api_backoff(func): """ Decorator, Handles HTTP 429 "Too Many Requests" messages from the Discord API If blocking=True is specified, this function will block and retry the function up to max_retries=n times, or 3 if retries is not specified. If the API call still recieves a backoff timer this fun...
[ "def", "api_backoff", "(", "func", ")", ":", "class", "PerformBackoff", "(", "Exception", ")", ":", "def", "__init__", "(", "self", ",", "retry_after", ",", "retry_datetime", ",", "global_ratelimit", ")", ":", "super", "(", "Exception", ",", "self", ")", "...
Decorator, Handles HTTP 429 "Too Many Requests" messages from the Discord API If blocking=True is specified, this function will block and retry the function up to max_retries=n times, or 3 if retries is not specified. If the API call still recieves a backoff timer this function will raise a <DiscordApiT...
[ "Decorator", "Handles", "HTTP", "429", "Too", "Many", "Requests", "messages", "from", "the", "Discord", "API", "If", "blocking", "=", "True", "is", "specified", "this", "function", "will", "block", "and", "retry", "the", "function", "up", "to", "max_retries", ...
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/services/modules/discord/manager.py#L67-L154
train
allianceauth/allianceauth
allianceauth/srp/views.py
random_string
def random_string(string_length=10): """Returns a random string of length string_length.""" random = str(uuid.uuid4()) # Convert UUID format to a Python string. random = random.upper() # Make all characters uppercase. random = random.replace("-", "") # Remove the UUID '-'. return random[0:string_...
python
def random_string(string_length=10): """Returns a random string of length string_length.""" random = str(uuid.uuid4()) # Convert UUID format to a Python string. random = random.upper() # Make all characters uppercase. random = random.replace("-", "") # Remove the UUID '-'. return random[0:string_...
[ "def", "random_string", "(", "string_length", "=", "10", ")", ":", "random", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "# Convert UUID format to a Python string.", "random", "=", "random", ".", "upper", "(", ")", "# Make all characters uppercase.", "...
Returns a random string of length string_length.
[ "Returns", "a", "random", "string", "of", "length", "string_length", "." ]
6585b07e96571a99a4d6dc03cc03f9b8c8f690ca
https://github.com/allianceauth/allianceauth/blob/6585b07e96571a99a4d6dc03cc03f9b8c8f690ca/allianceauth/srp/views.py#L25-L30
train
tariqdaouda/pyGeno
pyGeno/Genome.py
getGenomeList
def getGenomeList() : """Return the names of all imported genomes""" import rabaDB.filters as rfilt f = rfilt.RabaQuery(Genome_Raba) names = [] for g in f.iterRun() : names.append(g.name) return names
python
def getGenomeList() : """Return the names of all imported genomes""" import rabaDB.filters as rfilt f = rfilt.RabaQuery(Genome_Raba) names = [] for g in f.iterRun() : names.append(g.name) return names
[ "def", "getGenomeList", "(", ")", ":", "import", "rabaDB", ".", "filters", "as", "rfilt", "f", "=", "rfilt", ".", "RabaQuery", "(", "Genome_Raba", ")", "names", "=", "[", "]", "for", "g", "in", "f", ".", "iterRun", "(", ")", ":", "names", ".", "app...
Return the names of all imported genomes
[ "Return", "the", "names", "of", "all", "imported", "genomes" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/Genome.py#L16-L23
train
tariqdaouda/pyGeno
pyGeno/Transcript.py
Transcript.iterCodons
def iterCodons(self) : """iterates through the codons""" for i in range(len(self.cDNA)/3) : yield self.getCodon(i)
python
def iterCodons(self) : """iterates through the codons""" for i in range(len(self.cDNA)/3) : yield self.getCodon(i)
[ "def", "iterCodons", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "cDNA", ")", "/", "3", ")", ":", "yield", "self", ".", "getCodon", "(", "i", ")" ]
iterates through the codons
[ "iterates", "through", "the", "codons" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/Transcript.py#L165-L168
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
removeDuplicates
def removeDuplicates(inFileName, outFileName) : """removes duplicated lines from a 'inFileName' CSV file, the results are witten in 'outFileName'""" f = open(inFileName) legend = f.readline() data = '' h = {} h[legend] = 0 lines = f.readlines() for l in lines : if not h.has_key(l) : h[l] = 0 data +=...
python
def removeDuplicates(inFileName, outFileName) : """removes duplicated lines from a 'inFileName' CSV file, the results are witten in 'outFileName'""" f = open(inFileName) legend = f.readline() data = '' h = {} h[legend] = 0 lines = f.readlines() for l in lines : if not h.has_key(l) : h[l] = 0 data +=...
[ "def", "removeDuplicates", "(", "inFileName", ",", "outFileName", ")", ":", "f", "=", "open", "(", "inFileName", ")", "legend", "=", "f", ".", "readline", "(", ")", "data", "=", "''", "h", "=", "{", "}", "h", "[", "legend", "]", "=", "0", "lines", ...
removes duplicated lines from a 'inFileName' CSV file, the results are witten in 'outFileName
[ "removes", "duplicated", "lines", "from", "a", "inFileName", "CSV", "file", "the", "results", "are", "witten", "in", "outFileName" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L14-L34
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
catCSVs
def catCSVs(folder, ouputFileName, removeDups = False) : """Concatenates all csv in 'folder' and wites the results in 'ouputFileName'. My not work on non Unix systems""" strCmd = r"""cat %s/*.csv > %s""" %(folder, ouputFileName) os.system(strCmd) if removeDups : removeDuplicates(ouputFileName, ouputFileName)
python
def catCSVs(folder, ouputFileName, removeDups = False) : """Concatenates all csv in 'folder' and wites the results in 'ouputFileName'. My not work on non Unix systems""" strCmd = r"""cat %s/*.csv > %s""" %(folder, ouputFileName) os.system(strCmd) if removeDups : removeDuplicates(ouputFileName, ouputFileName)
[ "def", "catCSVs", "(", "folder", ",", "ouputFileName", ",", "removeDups", "=", "False", ")", ":", "strCmd", "=", "r\"\"\"cat %s/*.csv > %s\"\"\"", "%", "(", "folder", ",", "ouputFileName", ")", "os", ".", "system", "(", "strCmd", ")", "if", "removeDups", ":"...
Concatenates all csv in 'folder' and wites the results in 'ouputFileName'. My not work on non Unix systems
[ "Concatenates", "all", "csv", "in", "folder", "and", "wites", "the", "results", "in", "ouputFileName", ".", "My", "not", "work", "on", "non", "Unix", "systems" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L36-L42
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
joinCSVs
def joinCSVs(csvFilePaths, column, ouputFileName, separator = ',') : """csvFilePaths should be an iterable. Joins all CSVs according to the values in the column 'column'. Write the results in a new file 'ouputFileName' """ res = '' legend = [] csvs = [] for f in csvFilePaths : c = CSVFile() c.parse(f) cs...
python
def joinCSVs(csvFilePaths, column, ouputFileName, separator = ',') : """csvFilePaths should be an iterable. Joins all CSVs according to the values in the column 'column'. Write the results in a new file 'ouputFileName' """ res = '' legend = [] csvs = [] for f in csvFilePaths : c = CSVFile() c.parse(f) cs...
[ "def", "joinCSVs", "(", "csvFilePaths", ",", "column", ",", "ouputFileName", ",", "separator", "=", "','", ")", ":", "res", "=", "''", "legend", "=", "[", "]", "csvs", "=", "[", "]", "for", "f", "in", "csvFilePaths", ":", "c", "=", "CSVFile", "(", ...
csvFilePaths should be an iterable. Joins all CSVs according to the values in the column 'column'. Write the results in a new file 'ouputFileName'
[ "csvFilePaths", "should", "be", "an", "iterable", ".", "Joins", "all", "CSVs", "according", "to", "the", "values", "in", "the", "column", "column", ".", "Write", "the", "results", "in", "a", "new", "file", "ouputFileName" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L44-L76
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.addField
def addField(self, field) : """add a filed to the legend""" if field.lower() in self.legend : raise ValueError("%s is already in the legend" % field.lower()) self.legend[field.lower()] = len(self.legend) if len(self.strLegend) > 0 : self.strLegend += self.separator + field else : self.strLegend += f...
python
def addField(self, field) : """add a filed to the legend""" if field.lower() in self.legend : raise ValueError("%s is already in the legend" % field.lower()) self.legend[field.lower()] = len(self.legend) if len(self.strLegend) > 0 : self.strLegend += self.separator + field else : self.strLegend += f...
[ "def", "addField", "(", "self", ",", "field", ")", ":", "if", "field", ".", "lower", "(", ")", "in", "self", ".", "legend", ":", "raise", "ValueError", "(", "\"%s is already in the legend\"", "%", "field", ".", "lower", "(", ")", ")", "self", ".", "leg...
add a filed to the legend
[ "add", "a", "filed", "to", "the", "legend" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L221-L229
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.parse
def parse(self, filePath, skipLines=0, separator = ',', stringSeparator = '"', lineSeparator = '\n') : """Loads a CSV file""" self.filename = filePath f = open(filePath) if lineSeparator == '\n' : lines = f.readlines() else : lines = f.read().split(lineSeparator) f.flush() f.close() lines = ...
python
def parse(self, filePath, skipLines=0, separator = ',', stringSeparator = '"', lineSeparator = '\n') : """Loads a CSV file""" self.filename = filePath f = open(filePath) if lineSeparator == '\n' : lines = f.readlines() else : lines = f.read().split(lineSeparator) f.flush() f.close() lines = ...
[ "def", "parse", "(", "self", ",", "filePath", ",", "skipLines", "=", "0", ",", "separator", "=", "','", ",", "stringSeparator", "=", "'\"'", ",", "lineSeparator", "=", "'\\n'", ")", ":", "self", ".", "filename", "=", "filePath", "f", "=", "open", "(", ...
Loads a CSV file
[ "Loads", "a", "CSV", "file" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L231-L266
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.streamToFile
def streamToFile(self, filename, keepInMemory = False, writeRate = 1) : """Starts a stream to a file. Every line must be committed (l.commit()) to be appended in to the file. If keepInMemory is set to True, the parser will keep a version of the whole CSV in memory, writeRate is the number of lines that must be c...
python
def streamToFile(self, filename, keepInMemory = False, writeRate = 1) : """Starts a stream to a file. Every line must be committed (l.commit()) to be appended in to the file. If keepInMemory is set to True, the parser will keep a version of the whole CSV in memory, writeRate is the number of lines that must be c...
[ "def", "streamToFile", "(", "self", ",", "filename", ",", "keepInMemory", "=", "False", ",", "writeRate", "=", "1", ")", ":", "if", "len", "(", "self", ".", "legend", ")", "<", "1", ":", "raise", "ValueError", "(", "\"There's no legend defined\"", ")", "...
Starts a stream to a file. Every line must be committed (l.commit()) to be appended in to the file. If keepInMemory is set to True, the parser will keep a version of the whole CSV in memory, writeRate is the number of lines that must be committed before an automatic save is triggered.
[ "Starts", "a", "stream", "to", "a", "file", ".", "Every", "line", "must", "be", "committed", "(", "l", ".", "commit", "()", ")", "to", "be", "appended", "in", "to", "the", "file", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L278-L297
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.commitLine
def commitLine(self, line) : """Commits a line making it ready to be streamed to a file and saves the current buffer if needed. If no stream is active, raises a ValueError""" if self.streamBuffer is None : raise ValueError("Commit lines is only for when you are streaming to a file") self.streamBuffer.append(l...
python
def commitLine(self, line) : """Commits a line making it ready to be streamed to a file and saves the current buffer if needed. If no stream is active, raises a ValueError""" if self.streamBuffer is None : raise ValueError("Commit lines is only for when you are streaming to a file") self.streamBuffer.append(l...
[ "def", "commitLine", "(", "self", ",", "line", ")", ":", "if", "self", ".", "streamBuffer", "is", "None", ":", "raise", "ValueError", "(", "\"Commit lines is only for when you are streaming to a file\"", ")", "self", ".", "streamBuffer", ".", "append", "(", "line"...
Commits a line making it ready to be streamed to a file and saves the current buffer if needed. If no stream is active, raises a ValueError
[ "Commits", "a", "line", "making", "it", "ready", "to", "be", "streamed", "to", "a", "file", "and", "saves", "the", "current", "buffer", "if", "needed", ".", "If", "no", "stream", "is", "active", "raises", "a", "ValueError" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L299-L310
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.closeStreamToFile
def closeStreamToFile(self) : """Appends the remaining commited lines and closes the stream. If no stream is active, raises a ValueError""" if self.streamBuffer is None : raise ValueError("Commit lines is only for when you are streaming to a file") for i in xrange(len(self.streamBuffer)) : self.streamBuffe...
python
def closeStreamToFile(self) : """Appends the remaining commited lines and closes the stream. If no stream is active, raises a ValueError""" if self.streamBuffer is None : raise ValueError("Commit lines is only for when you are streaming to a file") for i in xrange(len(self.streamBuffer)) : self.streamBuffe...
[ "def", "closeStreamToFile", "(", "self", ")", ":", "if", "self", ".", "streamBuffer", "is", "None", ":", "raise", "ValueError", "(", "\"Commit lines is only for when you are streaming to a file\"", ")", "for", "i", "in", "xrange", "(", "len", "(", "self", ".", "...
Appends the remaining commited lines and closes the stream. If no stream is active, raises a ValueError
[ "Appends", "the", "remaining", "commited", "lines", "and", "closes", "the", "stream", ".", "If", "no", "stream", "is", "active", "raises", "a", "ValueError" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L312-L325
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.newLine
def newLine(self) : """Appends an empty line at the end of the CSV and returns it""" l = CSVEntry(self) if self.keepInMemory : self.lines.append(l) return l
python
def newLine(self) : """Appends an empty line at the end of the CSV and returns it""" l = CSVEntry(self) if self.keepInMemory : self.lines.append(l) return l
[ "def", "newLine", "(", "self", ")", ":", "l", "=", "CSVEntry", "(", "self", ")", "if", "self", ".", "keepInMemory", ":", "self", ".", "lines", ".", "append", "(", "l", ")", "return", "l" ]
Appends an empty line at the end of the CSV and returns it
[ "Appends", "an", "empty", "line", "at", "the", "end", "of", "the", "CSV", "and", "returns", "it" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L350-L355
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.insertLine
def insertLine(self, i) : """Inserts an empty line at position i and returns it""" self.data.insert(i, CSVEntry(self)) return self.lines[i]
python
def insertLine(self, i) : """Inserts an empty line at position i and returns it""" self.data.insert(i, CSVEntry(self)) return self.lines[i]
[ "def", "insertLine", "(", "self", ",", "i", ")", ":", "self", ".", "data", ".", "insert", "(", "i", ",", "CSVEntry", "(", "self", ")", ")", "return", "self", ".", "lines", "[", "i", "]" ]
Inserts an empty line at position i and returns it
[ "Inserts", "an", "empty", "line", "at", "position", "i", "and", "returns", "it" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L357-L360
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.save
def save(self, filePath) : """save the CSV to a file""" self.filename = filePath f = open(filePath, 'w') f.write(self.toStr()) f.flush() f.close()
python
def save(self, filePath) : """save the CSV to a file""" self.filename = filePath f = open(filePath, 'w') f.write(self.toStr()) f.flush() f.close()
[ "def", "save", "(", "self", ",", "filePath", ")", ":", "self", ".", "filename", "=", "filePath", "f", "=", "open", "(", "filePath", ",", "'w'", ")", "f", ".", "write", "(", "self", ".", "toStr", "(", ")", ")", "f", ".", "flush", "(", ")", "f", ...
save the CSV to a file
[ "save", "the", "CSV", "to", "a", "file" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L362-L368
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/CSVTools.py
CSVFile.toStr
def toStr(self) : """returns a string version of the CSV""" s = [self.strLegend] for l in self.lines : s.append(l.toStr()) return self.lineSeparator.join(s)
python
def toStr(self) : """returns a string version of the CSV""" s = [self.strLegend] for l in self.lines : s.append(l.toStr()) return self.lineSeparator.join(s)
[ "def", "toStr", "(", "self", ")", ":", "s", "=", "[", "self", ".", "strLegend", "]", "for", "l", "in", "self", ".", "lines", ":", "s", ".", "append", "(", "l", ".", "toStr", "(", ")", ")", "return", "self", ".", "lineSeparator", ".", "join", "(...
returns a string version of the CSV
[ "returns", "a", "string", "version", "of", "the", "CSV" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/CSVTools.py#L370-L375
train
tariqdaouda/pyGeno
pyGeno/pyGenoObjectBases.py
pyGenoRabaObjectWrapper.count
def count(self, objectType, *args, **coolArgs) : """Returns the number of elements satisfying the query""" return self._makeLoadQuery(objectType, *args, **coolArgs).count()
python
def count(self, objectType, *args, **coolArgs) : """Returns the number of elements satisfying the query""" return self._makeLoadQuery(objectType, *args, **coolArgs).count()
[ "def", "count", "(", "self", ",", "objectType", ",", "*", "args", ",", "*", "*", "coolArgs", ")", ":", "return", "self", ".", "_makeLoadQuery", "(", "objectType", ",", "*", "args", ",", "*", "*", "coolArgs", ")", ".", "count", "(", ")" ]
Returns the number of elements satisfying the query
[ "Returns", "the", "number", "of", "elements", "satisfying", "the", "query" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/pyGenoObjectBases.py#L112-L114
train
tariqdaouda/pyGeno
pyGeno/pyGenoObjectBases.py
pyGenoRabaObjectWrapper.get
def get(self, objectType, *args, **coolArgs) : """Raba Magic inside. This is th function that you use for querying pyGeno's DB. Usage examples: * myGenome.get("Gene", name = 'TPST2') * myGene.get(Protein, id = 'ENSID...') * myGenome.get(Transcript, {'start >' : x, 'end <' : y})""" ret =...
python
def get(self, objectType, *args, **coolArgs) : """Raba Magic inside. This is th function that you use for querying pyGeno's DB. Usage examples: * myGenome.get("Gene", name = 'TPST2') * myGene.get(Protein, id = 'ENSID...') * myGenome.get(Transcript, {'start >' : x, 'end <' : y})""" ret =...
[ "def", "get", "(", "self", ",", "objectType", ",", "*", "args", ",", "*", "*", "coolArgs", ")", ":", "ret", "=", "[", "]", "for", "e", "in", "self", ".", "_makeLoadQuery", "(", "objectType", ",", "*", "args", ",", "*", "*", "coolArgs", ")", ".", ...
Raba Magic inside. This is th function that you use for querying pyGeno's DB. Usage examples: * myGenome.get("Gene", name = 'TPST2') * myGene.get(Protein, id = 'ENSID...') * myGenome.get(Transcript, {'start >' : x, 'end <' : y})
[ "Raba", "Magic", "inside", ".", "This", "is", "th", "function", "that", "you", "use", "for", "querying", "pyGeno", "s", "DB", ".", "Usage", "examples", ":", "*", "myGenome", ".", "get", "(", "Gene", "name", "=", "TPST2", ")", "*", "myGene", ".", "get...
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/pyGenoObjectBases.py#L116-L135
train
tariqdaouda/pyGeno
pyGeno/pyGenoObjectBases.py
pyGenoRabaObjectWrapper.iterGet
def iterGet(self, objectType, *args, **coolArgs) : """Same as get. But retuns the elements one by one, much more efficient for large outputs""" for e in self._makeLoadQuery(objectType, *args, **coolArgs).iterRun() : if issubclass(objectType, pyGenoRabaObjectWrapper) : yield objectType(wrapped_object_and_bag...
python
def iterGet(self, objectType, *args, **coolArgs) : """Same as get. But retuns the elements one by one, much more efficient for large outputs""" for e in self._makeLoadQuery(objectType, *args, **coolArgs).iterRun() : if issubclass(objectType, pyGenoRabaObjectWrapper) : yield objectType(wrapped_object_and_bag...
[ "def", "iterGet", "(", "self", ",", "objectType", ",", "*", "args", ",", "*", "*", "coolArgs", ")", ":", "for", "e", "in", "self", ".", "_makeLoadQuery", "(", "objectType", ",", "*", "args", ",", "*", "*", "coolArgs", ")", ".", "iterRun", "(", ")",...
Same as get. But retuns the elements one by one, much more efficient for large outputs
[ "Same", "as", "get", ".", "But", "retuns", "the", "elements", "one", "by", "one", "much", "more", "efficient", "for", "large", "outputs" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/pyGenoObjectBases.py#L137-L144
train
tariqdaouda/pyGeno
pyGeno/importation/SNPs.py
importSNPs
def importSNPs(packageFile) : """The big wrapper, this function should detect the SNP type by the package manifest and then launch the corresponding function. Here's an example of a SNP manifest file for Casava SNPs:: [package_infos] description = Casava SNPs for testing purposes maintainer = Tariq Daouda ma...
python
def importSNPs(packageFile) : """The big wrapper, this function should detect the SNP type by the package manifest and then launch the corresponding function. Here's an example of a SNP manifest file for Casava SNPs:: [package_infos] description = Casava SNPs for testing purposes maintainer = Tariq Daouda ma...
[ "def", "importSNPs", "(", "packageFile", ")", ":", "printf", "(", "\"Importing polymorphism set: %s... (This may take a while)\"", "%", "packageFile", ")", "isDir", "=", "False", "if", "not", "os", ".", "path", ".", "isdir", "(", "packageFile", ")", ":", "packageD...
The big wrapper, this function should detect the SNP type by the package manifest and then launch the corresponding function. Here's an example of a SNP manifest file for Casava SNPs:: [package_infos] description = Casava SNPs for testing purposes maintainer = Tariq Daouda maintainer_contact = tariq.daouda [a...
[ "The", "big", "wrapper", "this", "function", "should", "detect", "the", "SNP", "type", "by", "the", "package", "manifest", "and", "then", "launch", "the", "corresponding", "function", ".", "Here", "s", "an", "example", "of", "a", "SNP", "manifest", "file", ...
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/SNPs.py#L14-L84
train
tariqdaouda/pyGeno
pyGeno/importation/SNPs.py
deleteSNPs
def deleteSNPs(setName) : """deletes a set of polymorphisms""" con = conf.db try : SMaster = SNPMaster(setName = setName) con.beginTransaction() SNPType = SMaster.SNPType con.delete(SNPType, 'setName = ?', (setName,)) SMaster.delete() con.endTransaction() except KeyError : raise KeyError("Can't delete...
python
def deleteSNPs(setName) : """deletes a set of polymorphisms""" con = conf.db try : SMaster = SNPMaster(setName = setName) con.beginTransaction() SNPType = SMaster.SNPType con.delete(SNPType, 'setName = ?', (setName,)) SMaster.delete() con.endTransaction() except KeyError : raise KeyError("Can't delete...
[ "def", "deleteSNPs", "(", "setName", ")", ":", "con", "=", "conf", ".", "db", "try", ":", "SMaster", "=", "SNPMaster", "(", "setName", "=", "setName", ")", "con", ".", "beginTransaction", "(", ")", "SNPType", "=", "SMaster", ".", "SNPType", "con", ".",...
deletes a set of polymorphisms
[ "deletes", "a", "set", "of", "polymorphisms" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/SNPs.py#L86-L100
train
tariqdaouda/pyGeno
pyGeno/importation/SNPs.py
_importSNPs_AgnosticSNP
def _importSNPs_AgnosticSNP(setName, species, genomeSource, snpsFile) : "This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno wil interpret all positions as 0 based" printf('importing SNP set %s for species %s...' % (setName, species)) snpData = CSVFile() snpData.parse(snps...
python
def _importSNPs_AgnosticSNP(setName, species, genomeSource, snpsFile) : "This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno wil interpret all positions as 0 based" printf('importing SNP set %s for species %s...' % (setName, species)) snpData = CSVFile() snpData.parse(snps...
[ "def", "_importSNPs_AgnosticSNP", "(", "setName", ",", "species", ",", "genomeSource", ",", "snpsFile", ")", ":", "printf", "(", "'importing SNP set %s for species %s...'", "%", "(", "setName", ",", "species", ")", ")", "snpData", "=", "CSVFile", "(", ")", "snpD...
This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno wil interpret all positions as 0 based
[ "This", "function", "will", "also", "create", "an", "index", "on", "start", "-", ">", "chromosomeNumber", "-", ">", "setName", ".", "Warning", ":", "pyGeno", "wil", "interpret", "all", "positions", "as", "0", "based" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/SNPs.py#L102-L148
train
tariqdaouda/pyGeno
pyGeno/importation/SNPs.py
_importSNPs_CasavaSNP
def _importSNPs_CasavaSNP(setName, species, genomeSource, snpsFile) : "This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno positions are 0 based" printf('importing SNP set %s for species %s...' % (setName, species)) snpData = SNPsTxtFile(snpsFile) CasavaSNP.dropIndex(('s...
python
def _importSNPs_CasavaSNP(setName, species, genomeSource, snpsFile) : "This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno positions are 0 based" printf('importing SNP set %s for species %s...' % (setName, species)) snpData = SNPsTxtFile(snpsFile) CasavaSNP.dropIndex(('s...
[ "def", "_importSNPs_CasavaSNP", "(", "setName", ",", "species", ",", "genomeSource", ",", "snpsFile", ")", ":", "printf", "(", "'importing SNP set %s for species %s...'", "%", "(", "setName", ",", "species", ")", ")", "snpData", "=", "SNPsTxtFile", "(", "snpsFile"...
This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno positions are 0 based
[ "This", "function", "will", "also", "create", "an", "index", "on", "start", "-", ">", "chromosomeNumber", "-", ">", "setName", ".", "Warning", ":", "pyGeno", "positions", "are", "0", "based" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/SNPs.py#L150-L195
train
tariqdaouda/pyGeno
pyGeno/importation/SNPs.py
_importSNPs_dbSNPSNP
def _importSNPs_dbSNPSNP(setName, species, genomeSource, snpsFile) : "This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno positions are 0 based" snpData = VCFFile(snpsFile, gziped = True, stream = True) dbSNPSNP.dropIndex(('start', 'chromosomeNumber', 'setName')) conf.db.be...
python
def _importSNPs_dbSNPSNP(setName, species, genomeSource, snpsFile) : "This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno positions are 0 based" snpData = VCFFile(snpsFile, gziped = True, stream = True) dbSNPSNP.dropIndex(('start', 'chromosomeNumber', 'setName')) conf.db.be...
[ "def", "_importSNPs_dbSNPSNP", "(", "setName", ",", "species", ",", "genomeSource", ",", "snpsFile", ")", ":", "snpData", "=", "VCFFile", "(", "snpsFile", ",", "gziped", "=", "True", ",", "stream", "=", "True", ")", "dbSNPSNP", ".", "dropIndex", "(", "(", ...
This function will also create an index on start->chromosomeNumber->setName. Warning : pyGeno positions are 0 based
[ "This", "function", "will", "also", "create", "an", "index", "on", "start", "-", ">", "chromosomeNumber", "-", ">", "setName", ".", "Warning", ":", "pyGeno", "positions", "are", "0", "based" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/SNPs.py#L197-L234
train
tariqdaouda/pyGeno
pyGeno/SNP.py
getSNPSetsList
def getSNPSetsList() : """Return the names of all imported snp sets""" import rabaDB.filters as rfilt f = rfilt.RabaQuery(SNPMaster) names = [] for g in f.iterRun() : names.append(g.setName) return names
python
def getSNPSetsList() : """Return the names of all imported snp sets""" import rabaDB.filters as rfilt f = rfilt.RabaQuery(SNPMaster) names = [] for g in f.iterRun() : names.append(g.setName) return names
[ "def", "getSNPSetsList", "(", ")", ":", "import", "rabaDB", ".", "filters", "as", "rfilt", "f", "=", "rfilt", ".", "RabaQuery", "(", "SNPMaster", ")", "names", "=", "[", "]", "for", "g", "in", "f", ".", "iterRun", "(", ")", ":", "names", ".", "appe...
Return the names of all imported snp sets
[ "Return", "the", "names", "of", "all", "imported", "snp", "sets" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/SNP.py#L18-L25
train
tariqdaouda/pyGeno
pyGeno/tools/io.py
printf
def printf(*s) : 'print + sys.stdout.flush()' for e in s[:-1] : print e, print s[-1] sys.stdout.flush()
python
def printf(*s) : 'print + sys.stdout.flush()' for e in s[:-1] : print e, print s[-1] sys.stdout.flush()
[ "def", "printf", "(", "*", "s", ")", ":", "for", "e", "in", "s", "[", ":", "-", "1", "]", ":", "print", "e", ",", "print", "s", "[", "-", "1", "]", "sys", ".", "stdout", ".", "flush", "(", ")" ]
print + sys.stdout.flush()
[ "print", "+", "sys", ".", "stdout", ".", "flush", "()" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/io.py#L3-L9
train
tariqdaouda/pyGeno
pyGeno/tools/Stats.py
kullback_leibler
def kullback_leibler(p, q) : """Discrete Kullback-Leibler divergence D(P||Q)""" p = np.asarray(p, dtype=np.float) q = np.asarray(q, dtype=np.float) if p.shape != q.shape : raise ValueError("p and q must be of the same dimensions") return np.sum(np.where(p > 0, np.log(p / q) * p, 0))
python
def kullback_leibler(p, q) : """Discrete Kullback-Leibler divergence D(P||Q)""" p = np.asarray(p, dtype=np.float) q = np.asarray(q, dtype=np.float) if p.shape != q.shape : raise ValueError("p and q must be of the same dimensions") return np.sum(np.where(p > 0, np.log(p / q) * p, 0))
[ "def", "kullback_leibler", "(", "p", ",", "q", ")", ":", "p", "=", "np", ".", "asarray", "(", "p", ",", "dtype", "=", "np", ".", "float", ")", "q", "=", "np", ".", "asarray", "(", "q", ",", "dtype", "=", "np", ".", "float", ")", "if", "p", ...
Discrete Kullback-Leibler divergence D(P||Q)
[ "Discrete", "Kullback", "-", "Leibler", "divergence", "D", "(", "P||Q", ")" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/Stats.py#L3-L11
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/FastaTools.py
FastaFile.parseFile
def parseFile(self, fil) : """Opens a file and parses it""" f = open(fil) self.parseStr(f.read()) f.close()
python
def parseFile(self, fil) : """Opens a file and parses it""" f = open(fil) self.parseStr(f.read()) f.close()
[ "def", "parseFile", "(", "self", ",", "fil", ")", ":", "f", "=", "open", "(", "fil", ")", "self", ".", "parseStr", "(", "f", ".", "read", "(", ")", ")", "f", ".", "close", "(", ")" ]
Opens a file and parses it
[ "Opens", "a", "file", "and", "parses", "it" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/FastaTools.py#L32-L36
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/FastaTools.py
FastaFile.add
def add(self, header, data) : """appends a new entry to the file""" if header[0] != '>' : self.data.append(('>'+header, data)) else : self.data.append((header, data))
python
def add(self, header, data) : """appends a new entry to the file""" if header[0] != '>' : self.data.append(('>'+header, data)) else : self.data.append((header, data))
[ "def", "add", "(", "self", ",", "header", ",", "data", ")", ":", "if", "header", "[", "0", "]", "!=", "'>'", ":", "self", ".", "data", ".", "append", "(", "(", "'>'", "+", "header", ",", "data", ")", ")", "else", ":", "self", ".", "data", "."...
appends a new entry to the file
[ "appends", "a", "new", "entry", "to", "the", "file" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/FastaTools.py#L52-L57
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
findAll
def findAll(haystack, needle) : """returns a list of all occurances of needle in haystack""" h = haystack res = [] f = haystack.find(needle) offset = 0 while (f >= 0) : #print h, needle, f, offset res.append(f+offset) offset += f+len(needle) h = h[f+len(needle):] f = h.find(needle) return res
python
def findAll(haystack, needle) : """returns a list of all occurances of needle in haystack""" h = haystack res = [] f = haystack.find(needle) offset = 0 while (f >= 0) : #print h, needle, f, offset res.append(f+offset) offset += f+len(needle) h = h[f+len(needle):] f = h.find(needle) return res
[ "def", "findAll", "(", "haystack", ",", "needle", ")", ":", "h", "=", "haystack", "res", "=", "[", "]", "f", "=", "haystack", ".", "find", "(", "needle", ")", "offset", "=", "0", "while", "(", "f", ">=", "0", ")", ":", "#print h, needle, f, offset", ...
returns a list of all occurances of needle in haystack
[ "returns", "a", "list", "of", "all", "occurances", "of", "needle", "in", "haystack" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L136-L150
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
complementTab
def complementTab(seq=[]): """returns a list of complementary sequence without inversing it""" complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A', 'R': 'Y', 'Y': 'R', 'M': 'K', 'K': 'M', 'W': 'W', 'S': 'S', 'B': 'V', 'D': 'H', 'H': 'D', 'V': 'B', 'N': 'N', 'a': 't', 'c': 'g...
python
def complementTab(seq=[]): """returns a list of complementary sequence without inversing it""" complement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A', 'R': 'Y', 'Y': 'R', 'M': 'K', 'K': 'M', 'W': 'W', 'S': 'S', 'B': 'V', 'D': 'H', 'H': 'D', 'V': 'B', 'N': 'N', 'a': 't', 'c': 'g...
[ "def", "complementTab", "(", "seq", "=", "[", "]", ")", ":", "complement", "=", "{", "'A'", ":", "'T'", ",", "'C'", ":", "'G'", ",", "'G'", ":", "'C'", ",", "'T'", ":", "'A'", ",", "'R'", ":", "'Y'", ",", "'Y'", ":", "'R'", ",", "'M'", ":", ...
returns a list of complementary sequence without inversing it
[ "returns", "a", "list", "of", "complementary", "sequence", "without", "inversing", "it" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L153-L174
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
translateDNA_6Frames
def translateDNA_6Frames(sequence) : """returns 6 translation of sequence. One for each reading frame""" trans = ( translateDNA(sequence, 'f1'), translateDNA(sequence, 'f2'), translateDNA(sequence, 'f3'), translateDNA(sequence, 'r1'), translateDNA(sequence, 'r2'), translateDNA(sequence, 'r3')...
python
def translateDNA_6Frames(sequence) : """returns 6 translation of sequence. One for each reading frame""" trans = ( translateDNA(sequence, 'f1'), translateDNA(sequence, 'f2'), translateDNA(sequence, 'f3'), translateDNA(sequence, 'r1'), translateDNA(sequence, 'r2'), translateDNA(sequence, 'r3')...
[ "def", "translateDNA_6Frames", "(", "sequence", ")", ":", "trans", "=", "(", "translateDNA", "(", "sequence", ",", "'f1'", ")", ",", "translateDNA", "(", "sequence", ",", "'f2'", ")", ",", "translateDNA", "(", "sequence", ",", "'f3'", ")", ",", "translateD...
returns 6 translation of sequence. One for each reading frame
[ "returns", "6", "translation", "of", "sequence", ".", "One", "for", "each", "reading", "frame" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L196-L208
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
translateDNA
def translateDNA(sequence, frame = 'f1', translTable_id='default') : """Translates DNA code, frame : fwd1, fwd2, fwd3, rev1, rev2, rev3""" protein = "" if frame == 'f1' : dna = sequence elif frame == 'f2': dna = sequence[1:] elif frame == 'f3' : dna = sequence[2:] elif frame == 'r1' : dna = reverseCompl...
python
def translateDNA(sequence, frame = 'f1', translTable_id='default') : """Translates DNA code, frame : fwd1, fwd2, fwd3, rev1, rev2, rev3""" protein = "" if frame == 'f1' : dna = sequence elif frame == 'f2': dna = sequence[1:] elif frame == 'f3' : dna = sequence[2:] elif frame == 'r1' : dna = reverseCompl...
[ "def", "translateDNA", "(", "sequence", ",", "frame", "=", "'f1'", ",", "translTable_id", "=", "'default'", ")", ":", "protein", "=", "\"\"", "if", "frame", "==", "'f1'", ":", "dna", "=", "sequence", "elif", "frame", "==", "'f2'", ":", "dna", "=", "seq...
Translates DNA code, frame : fwd1, fwd2, fwd3, rev1, rev2, rev3
[ "Translates", "DNA", "code", "frame", ":", "fwd1", "fwd2", "fwd3", "rev1", "rev2", "rev3" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L210-L250
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
getSequenceCombinaisons
def getSequenceCombinaisons(polymorphipolymorphicDnaSeqSeq, pos = 0) : """Takes a dna sequence with polymorphismes and returns all the possible sequences that it can yield""" if type(polymorphipolymorphicDnaSeqSeq) is not types.ListType : seq = list(polymorphipolymorphicDnaSeqSeq) else : seq = polymorphipolymor...
python
def getSequenceCombinaisons(polymorphipolymorphicDnaSeqSeq, pos = 0) : """Takes a dna sequence with polymorphismes and returns all the possible sequences that it can yield""" if type(polymorphipolymorphicDnaSeqSeq) is not types.ListType : seq = list(polymorphipolymorphicDnaSeqSeq) else : seq = polymorphipolymor...
[ "def", "getSequenceCombinaisons", "(", "polymorphipolymorphicDnaSeqSeq", ",", "pos", "=", "0", ")", ":", "if", "type", "(", "polymorphipolymorphicDnaSeqSeq", ")", "is", "not", "types", ".", "ListType", ":", "seq", "=", "list", "(", "polymorphipolymorphicDnaSeqSeq", ...
Takes a dna sequence with polymorphismes and returns all the possible sequences that it can yield
[ "Takes", "a", "dna", "sequence", "with", "polymorphismes", "and", "returns", "all", "the", "possible", "sequences", "that", "it", "can", "yield" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L252-L274
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
encodePolymorphicNucleotide
def encodePolymorphicNucleotide(polySeq) : """returns a single character encoding all nucletides of polySeq in a single character. PolySeq must have one of the following forms: ['A', 'T', 'G'], 'ATG', 'A/T/G'""" if type(polySeq) is types.StringType : if polySeq.find("/") < 0 : sseq = list(polySeq) else :...
python
def encodePolymorphicNucleotide(polySeq) : """returns a single character encoding all nucletides of polySeq in a single character. PolySeq must have one of the following forms: ['A', 'T', 'G'], 'ATG', 'A/T/G'""" if type(polySeq) is types.StringType : if polySeq.find("/") < 0 : sseq = list(polySeq) else :...
[ "def", "encodePolymorphicNucleotide", "(", "polySeq", ")", ":", "if", "type", "(", "polySeq", ")", "is", "types", ".", "StringType", ":", "if", "polySeq", ".", "find", "(", "\"/\"", ")", "<", "0", ":", "sseq", "=", "list", "(", "polySeq", ")", "else", ...
returns a single character encoding all nucletides of polySeq in a single character. PolySeq must have one of the following forms: ['A', 'T', 'G'], 'ATG', 'A/T/G
[ "returns", "a", "single", "character", "encoding", "all", "nucletides", "of", "polySeq", "in", "a", "single", "character", ".", "PolySeq", "must", "have", "one", "of", "the", "following", "forms", ":", "[", "A", "T", "G", "]", "ATG", "A", "/", "T", "/"...
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L280-L331
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
decodePolymorphicNucleotide
def decodePolymorphicNucleotide(nuc) : """the opposite of encodePolymorphicNucleotide, from 'R' to ['A', 'G']""" if nuc in polymorphicNucleotides : return polymorphicNucleotides[nuc] if nuc in nucleotides : return nuc raise ValueError('nuc: %s, is not a valid nucleotide' % nuc)
python
def decodePolymorphicNucleotide(nuc) : """the opposite of encodePolymorphicNucleotide, from 'R' to ['A', 'G']""" if nuc in polymorphicNucleotides : return polymorphicNucleotides[nuc] if nuc in nucleotides : return nuc raise ValueError('nuc: %s, is not a valid nucleotide' % nuc)
[ "def", "decodePolymorphicNucleotide", "(", "nuc", ")", ":", "if", "nuc", "in", "polymorphicNucleotides", ":", "return", "polymorphicNucleotides", "[", "nuc", "]", "if", "nuc", "in", "nucleotides", ":", "return", "nuc", "raise", "ValueError", "(", "'nuc: %s, is not...
the opposite of encodePolymorphicNucleotide, from 'R' to ['A', 'G']
[ "the", "opposite", "of", "encodePolymorphicNucleotide", "from", "R", "to", "[", "A", "G", "]" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L333-L341
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
getNucleotideCodon
def getNucleotideCodon(sequence, x1) : """Returns the entire codon of the nucleotide at pos x1 in sequence, and the position of that nocleotide in the codon in a tuple""" if x1 < 0 or x1 >= len(sequence) : return None p = x1%3 if p == 0 : return (sequence[x1: x1+3], 0) elif p ==1 : return (sequence[x1-1:...
python
def getNucleotideCodon(sequence, x1) : """Returns the entire codon of the nucleotide at pos x1 in sequence, and the position of that nocleotide in the codon in a tuple""" if x1 < 0 or x1 >= len(sequence) : return None p = x1%3 if p == 0 : return (sequence[x1: x1+3], 0) elif p ==1 : return (sequence[x1-1:...
[ "def", "getNucleotideCodon", "(", "sequence", ",", "x1", ")", ":", "if", "x1", "<", "0", "or", "x1", ">=", "len", "(", "sequence", ")", ":", "return", "None", "p", "=", "x1", "%", "3", "if", "p", "==", "0", ":", "return", "(", "sequence", "[", ...
Returns the entire codon of the nucleotide at pos x1 in sequence, and the position of that nocleotide in the codon in a tuple
[ "Returns", "the", "entire", "codon", "of", "the", "nucleotide", "at", "pos", "x1", "in", "sequence", "and", "the", "position", "of", "that", "nocleotide", "in", "the", "codon", "in", "a", "tuple" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L348-L361
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
showDifferences
def showDifferences(seq1, seq2) : """Returns a string highligthing differences between seq1 and seq2: * Matches by '-' * Differences : 'A|T' * Exceeded length : '#' """ ret = [] for i in range(max(len(seq1), len(seq2))) : if i >= len(seq1) : c1 = '#' else : c1 = seq1[i] if i >= len(seq2) : ...
python
def showDifferences(seq1, seq2) : """Returns a string highligthing differences between seq1 and seq2: * Matches by '-' * Differences : 'A|T' * Exceeded length : '#' """ ret = [] for i in range(max(len(seq1), len(seq2))) : if i >= len(seq1) : c1 = '#' else : c1 = seq1[i] if i >= len(seq2) : ...
[ "def", "showDifferences", "(", "seq1", ",", "seq2", ")", ":", "ret", "=", "[", "]", "for", "i", "in", "range", "(", "max", "(", "len", "(", "seq1", ")", ",", "len", "(", "seq2", ")", ")", ")", ":", "if", "i", ">=", "len", "(", "seq1", ")", ...
Returns a string highligthing differences between seq1 and seq2: * Matches by '-' * Differences : 'A|T' * Exceeded length : '#'
[ "Returns", "a", "string", "highligthing", "differences", "between", "seq1", "and", "seq2", ":", "*", "Matches", "by", "-", "*", "Differences", ":", "A|T", "*", "Exceeded", "length", ":", "#" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L363-L390
train
tariqdaouda/pyGeno
pyGeno/tools/UsefulFunctions.py
highlightSubsequence
def highlightSubsequence(sequence, x1, x2, start=' [', stop = '] ') : """returns a sequence where the subsequence in [x1, x2[ is placed in bewteen 'start' and 'stop'""" seq = list(sequence) print x1, x2-1, len(seq) seq[x1] = start + seq[x1] seq[x2-1] = seq[x2-1] + stop return ''.join(seq)
python
def highlightSubsequence(sequence, x1, x2, start=' [', stop = '] ') : """returns a sequence where the subsequence in [x1, x2[ is placed in bewteen 'start' and 'stop'""" seq = list(sequence) print x1, x2-1, len(seq) seq[x1] = start + seq[x1] seq[x2-1] = seq[x2-1] + stop return ''.join(seq)
[ "def", "highlightSubsequence", "(", "sequence", ",", "x1", ",", "x2", ",", "start", "=", "' ['", ",", "stop", "=", "'] '", ")", ":", "seq", "=", "list", "(", "sequence", ")", "print", "x1", ",", "x2", "-", "1", ",", "len", "(", "seq", ")", "seq",...
returns a sequence where the subsequence in [x1, x2[ is placed in bewteen 'start' and 'stop
[ "returns", "a", "sequence", "where", "the", "subsequence", "in", "[", "x1", "x2", "[", "is", "placed", "in", "bewteen", "start", "and", "stop" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/UsefulFunctions.py#L392-L400
train
tariqdaouda/pyGeno
pyGeno/importation/Genomes.py
backUpDB
def backUpDB() : """backup the current database version. automatically called by importGenome(). Returns the filename of the backup""" st = time.ctime().replace(' ', '_') fn = conf.pyGeno_RABA_DBFILE.replace('.db', '_%s-bck.db' % st) shutil.copy2(conf.pyGeno_RABA_DBFILE, fn) return fn
python
def backUpDB() : """backup the current database version. automatically called by importGenome(). Returns the filename of the backup""" st = time.ctime().replace(' ', '_') fn = conf.pyGeno_RABA_DBFILE.replace('.db', '_%s-bck.db' % st) shutil.copy2(conf.pyGeno_RABA_DBFILE, fn) return fn
[ "def", "backUpDB", "(", ")", ":", "st", "=", "time", ".", "ctime", "(", ")", ".", "replace", "(", "' '", ",", "'_'", ")", "fn", "=", "conf", ".", "pyGeno_RABA_DBFILE", ".", "replace", "(", "'.db'", ",", "'_%s-bck.db'", "%", "st", ")", "shutil", "."...
backup the current database version. automatically called by importGenome(). Returns the filename of the backup
[ "backup", "the", "current", "database", "version", ".", "automatically", "called", "by", "importGenome", "()", ".", "Returns", "the", "filename", "of", "the", "backup" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/Genomes.py#L22-L28
train
tariqdaouda/pyGeno
pyGeno/importation/Genomes.py
deleteGenome
def deleteGenome(species, name) : """Removes a genome from the database""" printf('deleting genome (%s, %s)...' % (species, name)) conf.db.beginTransaction() objs = [] allGood = True try : genome = Genome_Raba(name = name, species = species.lower()) objs.append(genome) ...
python
def deleteGenome(species, name) : """Removes a genome from the database""" printf('deleting genome (%s, %s)...' % (species, name)) conf.db.beginTransaction() objs = [] allGood = True try : genome = Genome_Raba(name = name, species = species.lower()) objs.append(genome) ...
[ "def", "deleteGenome", "(", "species", ",", "name", ")", ":", "printf", "(", "'deleting genome (%s, %s)...'", "%", "(", "species", ",", "name", ")", ")", "conf", ".", "db", ".", "beginTransaction", "(", ")", "objs", "=", "[", "]", "allGood", "=", "True",...
Removes a genome from the database
[ "Removes", "a", "genome", "from", "the", "database" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/Genomes.py#L58-L97
train
tariqdaouda/pyGeno
pyGeno/importation/Genomes.py
importGenome
def importGenome(packageFile, batchSize = 50, verbose = 0) : """Import a pyGeno genome package. A genome packages is folder or a tar.gz ball that contains at it's root: * gziped fasta files for all chromosomes, or URLs from where them must be downloaded * gziped GTF gene_set file from Ensembl, or an U...
python
def importGenome(packageFile, batchSize = 50, verbose = 0) : """Import a pyGeno genome package. A genome packages is folder or a tar.gz ball that contains at it's root: * gziped fasta files for all chromosomes, or URLs from where them must be downloaded * gziped GTF gene_set file from Ensembl, or an U...
[ "def", "importGenome", "(", "packageFile", ",", "batchSize", "=", "50", ",", "verbose", "=", "0", ")", ":", "def", "reformatItems", "(", "items", ")", ":", "s", "=", "str", "(", "items", ")", "s", "=", "s", ".", "replace", "(", "'['", ",", "''", ...
Import a pyGeno genome package. A genome packages is folder or a tar.gz ball that contains at it's root: * gziped fasta files for all chromosomes, or URLs from where them must be downloaded * gziped GTF gene_set file from Ensembl, or an URL from where it must be downloaded * a manifest.ini file s...
[ "Import", "a", "pyGeno", "genome", "package", ".", "A", "genome", "packages", "is", "folder", "or", "a", "tar", ".", "gz", "ball", "that", "contains", "at", "it", "s", "root", ":" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/Genomes.py#L99-L198
train
tariqdaouda/pyGeno
pyGeno/importation/Genomes.py
_importGenomeObjects
def _importGenomeObjects(gtfFilePath, chroSet, genome, batchSize, verbose = 0) : """verbose must be an int [0, 4] for various levels of verbosity""" class Store(object) : def __init__(self, conf) : self.conf = conf self.chromosomes = {} self.gen...
python
def _importGenomeObjects(gtfFilePath, chroSet, genome, batchSize, verbose = 0) : """verbose must be an int [0, 4] for various levels of verbosity""" class Store(object) : def __init__(self, conf) : self.conf = conf self.chromosomes = {} self.gen...
[ "def", "_importGenomeObjects", "(", "gtfFilePath", ",", "chroSet", ",", "genome", ",", "batchSize", ",", "verbose", "=", "0", ")", ":", "class", "Store", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "conf", ")", ":", "self", ".", "conf...
verbose must be an int [0, 4] for various levels of verbosity
[ "verbose", "must", "be", "an", "int", "[", "0", "4", "]", "for", "various", "levels", "of", "verbosity" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/Genomes.py#L201-L442
train
tariqdaouda/pyGeno
pyGeno/importation/Genomes.py
_importSequence
def _importSequence(chromosome, fastaFile, targetDir) : "Serializes fastas into .dat files" f = gzip.open(fastaFile) header = f.readline() strRes = f.read().upper().replace('\n', '').replace('\r', '') f.close() fn = '%s/chromosome%s.dat' % (targetDir, chromosome.number) f = open(fn, 'w') ...
python
def _importSequence(chromosome, fastaFile, targetDir) : "Serializes fastas into .dat files" f = gzip.open(fastaFile) header = f.readline() strRes = f.read().upper().replace('\n', '').replace('\r', '') f.close() fn = '%s/chromosome%s.dat' % (targetDir, chromosome.number) f = open(fn, 'w') ...
[ "def", "_importSequence", "(", "chromosome", ",", "fastaFile", ",", "targetDir", ")", ":", "f", "=", "gzip", ".", "open", "(", "fastaFile", ")", "header", "=", "f", ".", "readline", "(", ")", "strRes", "=", "f", ".", "read", "(", ")", ".", "upper", ...
Serializes fastas into .dat files
[ "Serializes", "fastas", "into", ".", "dat", "files" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/importation/Genomes.py#L445-L459
train
tariqdaouda/pyGeno
pyGeno/configuration.py
createDefaultConfigFile
def createDefaultConfigFile() : """Creates a default configuration file""" s = "[pyGeno_config]\nsettings_dir=%s\nremote_location=%s" % (pyGeno_SETTINGS_DIR, pyGeno_REMOTE_LOCATION) f = open('%s/config.ini' % pyGeno_SETTINGS_DIR, 'w') f.write(s) f.close()
python
def createDefaultConfigFile() : """Creates a default configuration file""" s = "[pyGeno_config]\nsettings_dir=%s\nremote_location=%s" % (pyGeno_SETTINGS_DIR, pyGeno_REMOTE_LOCATION) f = open('%s/config.ini' % pyGeno_SETTINGS_DIR, 'w') f.write(s) f.close()
[ "def", "createDefaultConfigFile", "(", ")", ":", "s", "=", "\"[pyGeno_config]\\nsettings_dir=%s\\nremote_location=%s\"", "%", "(", "pyGeno_SETTINGS_DIR", ",", "pyGeno_REMOTE_LOCATION", ")", "f", "=", "open", "(", "'%s/config.ini'", "%", "pyGeno_SETTINGS_DIR", ",", "'w'", ...
Creates a default configuration file
[ "Creates", "a", "default", "configuration", "file" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/configuration.py#L46-L51
train
tariqdaouda/pyGeno
pyGeno/configuration.py
getSettingsPath
def getSettingsPath() : """Returns the path where the settings are stored""" parser = SafeConfigParser() try : parser.read(os.path.normpath(pyGeno_SETTINGS_DIR+'/config.ini')) return parser.get('pyGeno_config', 'settings_dir') except : createDefaultConfigFile() return getSettingsPath()
python
def getSettingsPath() : """Returns the path where the settings are stored""" parser = SafeConfigParser() try : parser.read(os.path.normpath(pyGeno_SETTINGS_DIR+'/config.ini')) return parser.get('pyGeno_config', 'settings_dir') except : createDefaultConfigFile() return getSettingsPath()
[ "def", "getSettingsPath", "(", ")", ":", "parser", "=", "SafeConfigParser", "(", ")", "try", ":", "parser", ".", "read", "(", "os", ".", "path", ".", "normpath", "(", "pyGeno_SETTINGS_DIR", "+", "'/config.ini'", ")", ")", "return", "parser", ".", "get", ...
Returns the path where the settings are stored
[ "Returns", "the", "path", "where", "the", "settings", "are", "stored" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/configuration.py#L53-L61
train
tariqdaouda/pyGeno
pyGeno/configuration.py
pyGeno_init
def pyGeno_init() : """This function is automatically called at launch""" global db, dbConf global pyGeno_SETTINGS_PATH global pyGeno_RABA_DBFILE global pyGeno_DATA_PATH if not checkPythonVersion() : raise PythonVersionError("==> FATAL: pyGeno only works with python 2.7 and above, please upgrade your pyth...
python
def pyGeno_init() : """This function is automatically called at launch""" global db, dbConf global pyGeno_SETTINGS_PATH global pyGeno_RABA_DBFILE global pyGeno_DATA_PATH if not checkPythonVersion() : raise PythonVersionError("==> FATAL: pyGeno only works with python 2.7 and above, please upgrade your pyth...
[ "def", "pyGeno_init", "(", ")", ":", "global", "db", ",", "dbConf", "global", "pyGeno_SETTINGS_PATH", "global", "pyGeno_RABA_DBFILE", "global", "pyGeno_DATA_PATH", "if", "not", "checkPythonVersion", "(", ")", ":", "raise", "PythonVersionError", "(", "\"==> FATAL: pyGe...
This function is automatically called at launch
[ "This", "function", "is", "automatically", "called", "at", "launch" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/configuration.py#L76-L104
train
tariqdaouda/pyGeno
pyGeno/Exon.py
Exon.pluck
def pluck(self) : """Returns a plucked object. Plucks the exon off the tree, set the value of self.transcript into str(self.transcript). This effectively disconnects the object and makes it much more lighter in case you'd like to pickle it""" e = copy.copy(self) e.transcript = str(self.transcript) return e
python
def pluck(self) : """Returns a plucked object. Plucks the exon off the tree, set the value of self.transcript into str(self.transcript). This effectively disconnects the object and makes it much more lighter in case you'd like to pickle it""" e = copy.copy(self) e.transcript = str(self.transcript) return e
[ "def", "pluck", "(", "self", ")", ":", "e", "=", "copy", ".", "copy", "(", "self", ")", "e", ".", "transcript", "=", "str", "(", "self", ".", "transcript", ")", "return", "e" ]
Returns a plucked object. Plucks the exon off the tree, set the value of self.transcript into str(self.transcript). This effectively disconnects the object and makes it much more lighter in case you'd like to pickle it
[ "Returns", "a", "plucked", "object", ".", "Plucks", "the", "exon", "off", "the", "tree", "set", "the", "value", "of", "self", ".", "transcript", "into", "str", "(", "self", ".", "transcript", ")", ".", "This", "effectively", "disconnects", "the", "object",...
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/Exon.py#L138-L143
train
tariqdaouda/pyGeno
pyGeno/Exon.py
Exon.previousExon
def previousExon(self) : """Returns the previous exon of the transcript, or None if there is none""" if self.number == 0 : return None try : return self.transcript.exons[self.number-1] except IndexError : return None
python
def previousExon(self) : """Returns the previous exon of the transcript, or None if there is none""" if self.number == 0 : return None try : return self.transcript.exons[self.number-1] except IndexError : return None
[ "def", "previousExon", "(", "self", ")", ":", "if", "self", ".", "number", "==", "0", ":", "return", "None", "try", ":", "return", "self", ".", "transcript", ".", "exons", "[", "self", ".", "number", "-", "1", "]", "except", "IndexError", ":", "retur...
Returns the previous exon of the transcript, or None if there is none
[ "Returns", "the", "previous", "exon", "of", "the", "transcript", "or", "None", "if", "there", "is", "none" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/Exon.py#L152-L161
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/FastqTools.py
FastqFile.parseStr
def parseStr(self, st) : """Parses a string""" self.data = st.replace('\r', '\n') self.data = self.data.replace('\n\n', '\n') self.data = self.data.split('\n')
python
def parseStr(self, st) : """Parses a string""" self.data = st.replace('\r', '\n') self.data = self.data.replace('\n\n', '\n') self.data = self.data.split('\n')
[ "def", "parseStr", "(", "self", ",", "st", ")", ":", "self", ".", "data", "=", "st", ".", "replace", "(", "'\\r'", ",", "'\\n'", ")", "self", ".", "data", "=", "self", ".", "data", ".", "replace", "(", "'\\n\\n'", ",", "'\\n'", ")", "self", ".", ...
Parses a string
[ "Parses", "a", "string" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/FastqTools.py#L51-L55
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/FastqTools.py
FastqFile.get
def get(self, li) : """returns the ith entry""" i = li*4 self.__splitEntry(i) return self.data[i]
python
def get(self, li) : """returns the ith entry""" i = li*4 self.__splitEntry(i) return self.data[i]
[ "def", "get", "(", "self", ",", "li", ")", ":", "i", "=", "li", "*", "4", "self", ".", "__splitEntry", "(", "i", ")", "return", "self", ".", "data", "[", "i", "]" ]
returns the ith entry
[ "returns", "the", "ith", "entry" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/FastqTools.py#L70-L74
train
tariqdaouda/pyGeno
pyGeno/tools/parsers/FastqTools.py
FastqFile.newEntry
def newEntry(self, ident = "", seq = "", plus = "", qual = "") : """Appends an empty entry at the end of the CSV and returns it""" e = FastqEntry() self.data.append(e) return e
python
def newEntry(self, ident = "", seq = "", plus = "", qual = "") : """Appends an empty entry at the end of the CSV and returns it""" e = FastqEntry() self.data.append(e) return e
[ "def", "newEntry", "(", "self", ",", "ident", "=", "\"\"", ",", "seq", "=", "\"\"", ",", "plus", "=", "\"\"", ",", "qual", "=", "\"\"", ")", ":", "e", "=", "FastqEntry", "(", ")", "self", ".", "data", ".", "append", "(", "e", ")", "return", "e"...
Appends an empty entry at the end of the CSV and returns it
[ "Appends", "an", "empty", "entry", "at", "the", "end", "of", "the", "CSV", "and", "returns", "it" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/parsers/FastqTools.py#L76-L80
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
listRemoteDatawraps
def listRemoteDatawraps(location = conf.pyGeno_REMOTE_LOCATION) : """Lists all the datawraps availabe from a remote a remote location.""" loc = location + "/datawraps.json" response = urllib2.urlopen(loc) js = json.loads(response.read()) return js
python
def listRemoteDatawraps(location = conf.pyGeno_REMOTE_LOCATION) : """Lists all the datawraps availabe from a remote a remote location.""" loc = location + "/datawraps.json" response = urllib2.urlopen(loc) js = json.loads(response.read()) return js
[ "def", "listRemoteDatawraps", "(", "location", "=", "conf", ".", "pyGeno_REMOTE_LOCATION", ")", ":", "loc", "=", "location", "+", "\"/datawraps.json\"", "response", "=", "urllib2", ".", "urlopen", "(", "loc", ")", "js", "=", "json", ".", "loads", "(", "respo...
Lists all the datawraps availabe from a remote a remote location.
[ "Lists", "all", "the", "datawraps", "availabe", "from", "a", "remote", "a", "remote", "location", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L11-L17
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
printRemoteDatawraps
def printRemoteDatawraps(location = conf.pyGeno_REMOTE_LOCATION) : """ print all available datawraps from a remote location the location must have a datawraps.json in the following format:: { "Ordered": { "Reference genomes": { "Human" : ["GRCh37.75", "GRCh38.78"], "Mouse" : ["GRCm38.78"], }...
python
def printRemoteDatawraps(location = conf.pyGeno_REMOTE_LOCATION) : """ print all available datawraps from a remote location the location must have a datawraps.json in the following format:: { "Ordered": { "Reference genomes": { "Human" : ["GRCh37.75", "GRCh38.78"], "Mouse" : ["GRCm38.78"], }...
[ "def", "printRemoteDatawraps", "(", "location", "=", "conf", ".", "pyGeno_REMOTE_LOCATION", ")", ":", "l", "=", "listRemoteDatawraps", "(", "location", ")", "printf", "(", "\"Available datawraps for bootstraping\\n\"", ")", "print", "json", ".", "dumps", "(", "l", ...
print all available datawraps from a remote location the location must have a datawraps.json in the following format:: { "Ordered": { "Reference genomes": { "Human" : ["GRCh37.75", "GRCh38.78"], "Mouse" : ["GRCm38.78"], }, "SNPs":{ } }, "Flat":{ "Reference genomes": { "G...
[ "print", "all", "available", "datawraps", "from", "a", "remote", "location", "the", "location", "must", "have", "a", "datawraps", ".", "json", "in", "the", "following", "format", "::" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L19-L47
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
importRemoteGenome
def importRemoteGenome(name, batchSize = 100) : """Import a genome available from http://pygeno.iric.ca (might work).""" try : dw = listRemoteDatawraps()["Flat"]["Reference genomes"][name] except AttributeError : raise AttributeError("There's no remote genome datawrap by the name of: '%s'" % name) finalFile = ...
python
def importRemoteGenome(name, batchSize = 100) : """Import a genome available from http://pygeno.iric.ca (might work).""" try : dw = listRemoteDatawraps()["Flat"]["Reference genomes"][name] except AttributeError : raise AttributeError("There's no remote genome datawrap by the name of: '%s'" % name) finalFile = ...
[ "def", "importRemoteGenome", "(", "name", ",", "batchSize", "=", "100", ")", ":", "try", ":", "dw", "=", "listRemoteDatawraps", "(", ")", "[", "\"Flat\"", "]", "[", "\"Reference genomes\"", "]", "[", "name", "]", "except", "AttributeError", ":", "raise", "...
Import a genome available from http://pygeno.iric.ca (might work).
[ "Import", "a", "genome", "available", "from", "http", ":", "//", "pygeno", ".", "iric", ".", "ca", "(", "might", "work", ")", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L58-L66
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
importRemoteSNPs
def importRemoteSNPs(name) : """Import a SNP set available from http://pygeno.iric.ca (might work).""" try : dw = listRemoteDatawraps()["Flat"]["SNPs"] except AttributeError : raise AttributeError("There's no remote genome datawrap by the name of: '%s'" % name) finalFile = _DW(name, dw["url"]) PS.importSNPs(f...
python
def importRemoteSNPs(name) : """Import a SNP set available from http://pygeno.iric.ca (might work).""" try : dw = listRemoteDatawraps()["Flat"]["SNPs"] except AttributeError : raise AttributeError("There's no remote genome datawrap by the name of: '%s'" % name) finalFile = _DW(name, dw["url"]) PS.importSNPs(f...
[ "def", "importRemoteSNPs", "(", "name", ")", ":", "try", ":", "dw", "=", "listRemoteDatawraps", "(", ")", "[", "\"Flat\"", "]", "[", "\"SNPs\"", "]", "except", "AttributeError", ":", "raise", "AttributeError", "(", "\"There's no remote genome datawrap by the name of...
Import a SNP set available from http://pygeno.iric.ca (might work).
[ "Import", "a", "SNP", "set", "available", "from", "http", ":", "//", "pygeno", ".", "iric", ".", "ca", "(", "might", "work", ")", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L68-L76
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
listDatawraps
def listDatawraps() : """Lists all the datawraps pyGeno comes with""" l = {"Genomes" : [], "SNPs" : []} for f in os.listdir(os.path.join(this_dir, "bootstrap_data/genomes")) : if f.find(".tar.gz") > -1 : l["Genomes"].append(f) for f in os.listdir(os.path.join(this_dir, "bootstrap_data/SNPs")) : if f.find("...
python
def listDatawraps() : """Lists all the datawraps pyGeno comes with""" l = {"Genomes" : [], "SNPs" : []} for f in os.listdir(os.path.join(this_dir, "bootstrap_data/genomes")) : if f.find(".tar.gz") > -1 : l["Genomes"].append(f) for f in os.listdir(os.path.join(this_dir, "bootstrap_data/SNPs")) : if f.find("...
[ "def", "listDatawraps", "(", ")", ":", "l", "=", "{", "\"Genomes\"", ":", "[", "]", ",", "\"SNPs\"", ":", "[", "]", "}", "for", "f", "in", "os", ".", "listdir", "(", "os", ".", "path", ".", "join", "(", "this_dir", ",", "\"bootstrap_data/genomes\"", ...
Lists all the datawraps pyGeno comes with
[ "Lists", "all", "the", "datawraps", "pyGeno", "comes", "with" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L78-L89
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
printDatawraps
def printDatawraps() : """print all available datawraps for bootstraping""" l = listDatawraps() printf("Available datawraps for boostraping\n") for k, v in l.iteritems() : printf(k) printf("~"*len(k) + "|") for vv in v : printf(" "*len(k) + "|" + "~~~:> " + vv) printf('\n')
python
def printDatawraps() : """print all available datawraps for bootstraping""" l = listDatawraps() printf("Available datawraps for boostraping\n") for k, v in l.iteritems() : printf(k) printf("~"*len(k) + "|") for vv in v : printf(" "*len(k) + "|" + "~~~:> " + vv) printf('\n')
[ "def", "printDatawraps", "(", ")", ":", "l", "=", "listDatawraps", "(", ")", "printf", "(", "\"Available datawraps for boostraping\\n\"", ")", "for", "k", ",", "v", "in", "l", ".", "iteritems", "(", ")", ":", "printf", "(", "k", ")", "printf", "(", "\"~\...
print all available datawraps for bootstraping
[ "print", "all", "available", "datawraps", "for", "bootstraping" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L91-L100
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
importGenome
def importGenome(name, batchSize = 100) : """Import a genome shipped with pyGeno. Most of the datawraps only contain URLs towards data provided by third parties.""" path = os.path.join(this_dir, "bootstrap_data", "genomes/" + name) PG.importGenome(path, batchSize)
python
def importGenome(name, batchSize = 100) : """Import a genome shipped with pyGeno. Most of the datawraps only contain URLs towards data provided by third parties.""" path = os.path.join(this_dir, "bootstrap_data", "genomes/" + name) PG.importGenome(path, batchSize)
[ "def", "importGenome", "(", "name", ",", "batchSize", "=", "100", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "this_dir", ",", "\"bootstrap_data\"", ",", "\"genomes/\"", "+", "name", ")", "PG", ".", "importGenome", "(", "path", ",", "ba...
Import a genome shipped with pyGeno. Most of the datawraps only contain URLs towards data provided by third parties.
[ "Import", "a", "genome", "shipped", "with", "pyGeno", ".", "Most", "of", "the", "datawraps", "only", "contain", "URLs", "towards", "data", "provided", "by", "third", "parties", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L102-L105
train
tariqdaouda/pyGeno
pyGeno/bootstrap.py
importSNPs
def importSNPs(name) : """Import a SNP set shipped with pyGeno. Most of the datawraps only contain URLs towards data provided by third parties.""" path = os.path.join(this_dir, "bootstrap_data", "SNPs/" + name) PS.importSNPs(path)
python
def importSNPs(name) : """Import a SNP set shipped with pyGeno. Most of the datawraps only contain URLs towards data provided by third parties.""" path = os.path.join(this_dir, "bootstrap_data", "SNPs/" + name) PS.importSNPs(path)
[ "def", "importSNPs", "(", "name", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "this_dir", ",", "\"bootstrap_data\"", ",", "\"SNPs/\"", "+", "name", ")", "PS", ".", "importSNPs", "(", "path", ")" ]
Import a SNP set shipped with pyGeno. Most of the datawraps only contain URLs towards data provided by third parties.
[ "Import", "a", "SNP", "set", "shipped", "with", "pyGeno", ".", "Most", "of", "the", "datawraps", "only", "contain", "URLs", "towards", "data", "provided", "by", "third", "parties", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/bootstrap.py#L107-L110
train
tariqdaouda/pyGeno
pyGeno/tools/ProgressBar.py
ProgressBar.log
def log(self) : """logs stats about the progression, without printing anything on screen""" self.logs['epochDuration'].append(self.lastEpochDuration) self.logs['avg'].append(self.avg) self.logs['runtime'].append(self.runtime) self.logs['remtime'].append(self.remtime)
python
def log(self) : """logs stats about the progression, without printing anything on screen""" self.logs['epochDuration'].append(self.lastEpochDuration) self.logs['avg'].append(self.avg) self.logs['runtime'].append(self.runtime) self.logs['remtime'].append(self.remtime)
[ "def", "log", "(", "self", ")", ":", "self", ".", "logs", "[", "'epochDuration'", "]", ".", "append", "(", "self", ".", "lastEpochDuration", ")", "self", ".", "logs", "[", "'avg'", "]", ".", "append", "(", "self", ".", "avg", ")", "self", ".", "log...
logs stats about the progression, without printing anything on screen
[ "logs", "stats", "about", "the", "progression", "without", "printing", "anything", "on", "screen" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/ProgressBar.py#L60-L66
train
tariqdaouda/pyGeno
pyGeno/tools/ProgressBar.py
ProgressBar.saveLogs
def saveLogs(self, filename) : """dumps logs into a nice pickle""" f = open(filename, 'wb') cPickle.dump(self.logs, f) f.close()
python
def saveLogs(self, filename) : """dumps logs into a nice pickle""" f = open(filename, 'wb') cPickle.dump(self.logs, f) f.close()
[ "def", "saveLogs", "(", "self", ",", "filename", ")", ":", "f", "=", "open", "(", "filename", ",", "'wb'", ")", "cPickle", ".", "dump", "(", "self", ".", "logs", ",", "f", ")", "f", ".", "close", "(", ")" ]
dumps logs into a nice pickle
[ "dumps", "logs", "into", "a", "nice", "pickle" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/ProgressBar.py#L68-L72
train
tariqdaouda/pyGeno
pyGeno/tools/ProgressBar.py
ProgressBar.update
def update(self, label = '', forceRefresh = False, log = False) : """the function to be called at each iteration. Setting log = True is the same as calling log() just after update()""" self.currEpoch += 1 tim = time.time() if (tim - self.lastPrintTime > self.minRefeshTime) or forceRefresh : self._update() ...
python
def update(self, label = '', forceRefresh = False, log = False) : """the function to be called at each iteration. Setting log = True is the same as calling log() just after update()""" self.currEpoch += 1 tim = time.time() if (tim - self.lastPrintTime > self.minRefeshTime) or forceRefresh : self._update() ...
[ "def", "update", "(", "self", ",", "label", "=", "''", ",", "forceRefresh", "=", "False", ",", "log", "=", "False", ")", ":", "self", ".", "currEpoch", "+=", "1", "tim", "=", "time", ".", "time", "(", ")", "if", "(", "tim", "-", "self", ".", "l...
the function to be called at each iteration. Setting log = True is the same as calling log() just after update()
[ "the", "function", "to", "be", "called", "at", "each", "iteration", ".", "Setting", "log", "=", "True", "is", "the", "same", "as", "calling", "log", "()", "just", "after", "update", "()" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/ProgressBar.py#L74-L114
train
tariqdaouda/pyGeno
pyGeno/SNPFiltering.py
DefaultSNPFilter.filter
def filter(self, chromosome, **kwargs) : """The default filter mixes applied all SNPs and ignores Insertions and Deletions.""" def appendAllele(alleles, sources, snp) : pos = snp.start if snp.alt[0] == '-' : pass # print warn % ('DELETION', snpSet, snp.start, snp.chromosomeNumber) elif snp.ref[0] =...
python
def filter(self, chromosome, **kwargs) : """The default filter mixes applied all SNPs and ignores Insertions and Deletions.""" def appendAllele(alleles, sources, snp) : pos = snp.start if snp.alt[0] == '-' : pass # print warn % ('DELETION', snpSet, snp.start, snp.chromosomeNumber) elif snp.ref[0] =...
[ "def", "filter", "(", "self", ",", "chromosome", ",", "*", "*", "kwargs", ")", ":", "def", "appendAllele", "(", "alleles", ",", "sources", ",", "snp", ")", ":", "pos", "=", "snp", ".", "start", "if", "snp", ".", "alt", "[", "0", "]", "==", "'-'",...
The default filter mixes applied all SNPs and ignores Insertions and Deletions.
[ "The", "default", "filter", "mixes", "applied", "all", "SNPs", "and", "ignores", "Insertions", "and", "Deletions", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/SNPFiltering.py#L105-L137
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
aux_insertTree
def aux_insertTree(childTree, parentTree): """This a private (You shouldn't have to call it) recursive function that inserts a child tree into a parent tree.""" if childTree.x1 != None and childTree.x2 != None : parentTree.insert(childTree.x1, childTree.x2, childTree.name, childTree.referedObject) for c in childT...
python
def aux_insertTree(childTree, parentTree): """This a private (You shouldn't have to call it) recursive function that inserts a child tree into a parent tree.""" if childTree.x1 != None and childTree.x2 != None : parentTree.insert(childTree.x1, childTree.x2, childTree.name, childTree.referedObject) for c in childT...
[ "def", "aux_insertTree", "(", "childTree", ",", "parentTree", ")", ":", "if", "childTree", ".", "x1", "!=", "None", "and", "childTree", ".", "x2", "!=", "None", ":", "parentTree", ".", "insert", "(", "childTree", ".", "x1", ",", "childTree", ".", "x2", ...
This a private (You shouldn't have to call it) recursive function that inserts a child tree into a parent tree.
[ "This", "a", "private", "(", "You", "shouldn", "t", "have", "to", "call", "it", ")", "recursive", "function", "that", "inserts", "a", "child", "tree", "into", "a", "parent", "tree", "." ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L3-L9
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
aux_moveTree
def aux_moveTree(offset, tree): """This a private recursive (You shouldn't have to call it) function that translates tree(and it's children) to a given x1""" if tree.x1 != None and tree.x2 != None : tree.x1, tree.x2 = tree.x1+offset, tree.x2+offset for c in tree.children: aux_moveTree(offset, c)
python
def aux_moveTree(offset, tree): """This a private recursive (You shouldn't have to call it) function that translates tree(and it's children) to a given x1""" if tree.x1 != None and tree.x2 != None : tree.x1, tree.x2 = tree.x1+offset, tree.x2+offset for c in tree.children: aux_moveTree(offset, c)
[ "def", "aux_moveTree", "(", "offset", ",", "tree", ")", ":", "if", "tree", ".", "x1", "!=", "None", "and", "tree", ".", "x2", "!=", "None", ":", "tree", ".", "x1", ",", "tree", ".", "x2", "=", "tree", ".", "x1", "+", "offset", ",", "tree", ".",...
This a private recursive (You shouldn't have to call it) function that translates tree(and it's children) to a given x1
[ "This", "a", "private", "recursive", "(", "You", "shouldn", "t", "have", "to", "call", "it", ")", "function", "that", "translates", "tree", "(", "and", "it", "s", "children", ")", "to", "a", "given", "x1" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L11-L17
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.insert
def insert(self, x1, x2, name = '', referedObject = []) : """Insert the segment in it's right place and returns it. If there's already a segment S as S.x1 == x1 and S.x2 == x2. S.name will be changed to 'S.name U name' and the referedObject will be appended to the already existing list""" if x1 > x2 : xx...
python
def insert(self, x1, x2, name = '', referedObject = []) : """Insert the segment in it's right place and returns it. If there's already a segment S as S.x1 == x1 and S.x2 == x2. S.name will be changed to 'S.name U name' and the referedObject will be appended to the already existing list""" if x1 > x2 : xx...
[ "def", "insert", "(", "self", ",", "x1", ",", "x2", ",", "name", "=", "''", ",", "referedObject", "=", "[", "]", ")", ":", "if", "x1", ">", "x2", ":", "xx1", ",", "xx2", "=", "x2", ",", "x1", "else", ":", "xx1", ",", "xx2", "=", "x1", ",", ...
Insert the segment in it's right place and returns it. If there's already a segment S as S.x1 == x1 and S.x2 == x2. S.name will be changed to 'S.name U name' and the referedObject will be appended to the already existing list
[ "Insert", "the", "segment", "in", "it", "s", "right", "place", "and", "returns", "it", ".", "If", "there", "s", "already", "a", "segment", "S", "as", "S", ".", "x1", "==", "x1", "and", "S", ".", "x2", "==", "x2", ".", "S", ".", "name", "will", ...
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L77-L131
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.intersect
def intersect(self, x1, x2 = None) : """Returns a list of all segments intersected by [x1, x2]""" def condition(x1, x2, tree) : #print self.id, tree.x1, tree.x2, x1, x2 if (tree.x1 != None and tree.x2 != None) and (tree.x1 <= x1 and x1 < tree.x2 or tree.x1 <= x2 and x2 < tree.x2) : return True retur...
python
def intersect(self, x1, x2 = None) : """Returns a list of all segments intersected by [x1, x2]""" def condition(x1, x2, tree) : #print self.id, tree.x1, tree.x2, x1, x2 if (tree.x1 != None and tree.x2 != None) and (tree.x1 <= x1 and x1 < tree.x2 or tree.x1 <= x2 and x2 < tree.x2) : return True retur...
[ "def", "intersect", "(", "self", ",", "x1", ",", "x2", "=", "None", ")", ":", "def", "condition", "(", "x1", ",", "x2", ",", "tree", ")", ":", "#print self.id, tree.x1, tree.x2, x1, x2", "if", "(", "tree", ".", "x1", "!=", "None", "and", "tree", ".", ...
Returns a list of all segments intersected by [x1, x2]
[ "Returns", "a", "list", "of", "all", "segments", "intersected", "by", "[", "x1", "x2", "]" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L141-L177
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.__radiateDown
def __radiateDown(self, x1, x2, childId, condition) : "Radiates down: walks self.children downward until condition is no longer verifed or there's no childrens left " ret = [] i = childId while 0 <= i : if condition(x1, x2, self.children[i]) : ret.append(self.children[i]) else : break i -= 1 ...
python
def __radiateDown(self, x1, x2, childId, condition) : "Radiates down: walks self.children downward until condition is no longer verifed or there's no childrens left " ret = [] i = childId while 0 <= i : if condition(x1, x2, self.children[i]) : ret.append(self.children[i]) else : break i -= 1 ...
[ "def", "__radiateDown", "(", "self", ",", "x1", ",", "x2", ",", "childId", ",", "condition", ")", ":", "ret", "=", "[", "]", "i", "=", "childId", "while", "0", "<=", "i", ":", "if", "condition", "(", "x1", ",", "x2", ",", "self", ".", "children",...
Radiates down: walks self.children downward until condition is no longer verifed or there's no childrens left
[ "Radiates", "down", ":", "walks", "self", ".", "children", "downward", "until", "condition", "is", "no", "longer", "verifed", "or", "there", "s", "no", "childrens", "left" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L196-L206
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.__radiateUp
def __radiateUp(self, x1, x2, childId, condition) : "Radiates uo: walks self.children upward until condition is no longer verifed or there's no childrens left " ret = [] i = childId while i < len(self.children): if condition(x1, x2, self.children[i]) : ret.append(self.children[i]) else : break ...
python
def __radiateUp(self, x1, x2, childId, condition) : "Radiates uo: walks self.children upward until condition is no longer verifed or there's no childrens left " ret = [] i = childId while i < len(self.children): if condition(x1, x2, self.children[i]) : ret.append(self.children[i]) else : break ...
[ "def", "__radiateUp", "(", "self", ",", "x1", ",", "x2", ",", "childId", ",", "condition", ")", ":", "ret", "=", "[", "]", "i", "=", "childId", "while", "i", "<", "len", "(", "self", ".", "children", ")", ":", "if", "condition", "(", "x1", ",", ...
Radiates uo: walks self.children upward until condition is no longer verifed or there's no childrens left
[ "Radiates", "uo", ":", "walks", "self", ".", "children", "upward", "until", "condition", "is", "no", "longer", "verifed", "or", "there", "s", "no", "childrens", "left" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L208-L218
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.removeGaps
def removeGaps(self) : """Remove all gaps between regions""" for i in range(1, len(self.children)) : if self.children[i].x1 > self.children[i-1].x2: aux_moveTree(self.children[i-1].x2-self.children[i].x1, self.children[i])
python
def removeGaps(self) : """Remove all gaps between regions""" for i in range(1, len(self.children)) : if self.children[i].x1 > self.children[i-1].x2: aux_moveTree(self.children[i-1].x2-self.children[i].x1, self.children[i])
[ "def", "removeGaps", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "len", "(", "self", ".", "children", ")", ")", ":", "if", "self", ".", "children", "[", "i", "]", ".", "x1", ">", "self", ".", "children", "[", "i", "-", "1...
Remove all gaps between regions
[ "Remove", "all", "gaps", "between", "regions" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L224-L229
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.getIndexedLength
def getIndexedLength(self) : """Returns the total length of indexed regions""" if self.x1 != None and self.x2 != None: return self.x2 - self.x1 else : if len(self.children) == 0 : return 0 else : l = self.children[0].x2 - self.children[0].x1 for i in range(1, len(self.children)) : l += s...
python
def getIndexedLength(self) : """Returns the total length of indexed regions""" if self.x1 != None and self.x2 != None: return self.x2 - self.x1 else : if len(self.children) == 0 : return 0 else : l = self.children[0].x2 - self.children[0].x1 for i in range(1, len(self.children)) : l += s...
[ "def", "getIndexedLength", "(", "self", ")", ":", "if", "self", ".", "x1", "!=", "None", "and", "self", ".", "x2", "!=", "None", ":", "return", "self", ".", "x2", "-", "self", ".", "x1", "else", ":", "if", "len", "(", "self", ".", "children", ")"...
Returns the total length of indexed regions
[ "Returns", "the", "total", "length", "of", "indexed", "regions" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L243-L254
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.getFirstLevel
def getFirstLevel(self) : """returns a list of couples (x1, x2) of all the first level indexed regions""" res = [] if len(self.children) > 0 : for c in self.children: res.append((c.x1, c.x2)) else : if self.x1 != None : res = [(self.x1, self.x2)] else : res = None return res
python
def getFirstLevel(self) : """returns a list of couples (x1, x2) of all the first level indexed regions""" res = [] if len(self.children) > 0 : for c in self.children: res.append((c.x1, c.x2)) else : if self.x1 != None : res = [(self.x1, self.x2)] else : res = None return res
[ "def", "getFirstLevel", "(", "self", ")", ":", "res", "=", "[", "]", "if", "len", "(", "self", ".", "children", ")", ">", "0", ":", "for", "c", "in", "self", ".", "children", ":", "res", ".", "append", "(", "(", "c", ".", "x1", ",", "c", ".",...
returns a list of couples (x1, x2) of all the first level indexed regions
[ "returns", "a", "list", "of", "couples", "(", "x1", "x2", ")", "of", "all", "the", "first", "level", "indexed", "regions" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L256-L267
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.flatten
def flatten(self) : """Flattens the tree. The tree become a tree of depth 1 where overlapping regions have been merged together""" if len(self.children) > 1 : children = self.children self.emptyChildren() children[0].emptyChildren() x1 = children[0].x1 x2 = children[0].x2 refObjs = [children[0...
python
def flatten(self) : """Flattens the tree. The tree become a tree of depth 1 where overlapping regions have been merged together""" if len(self.children) > 1 : children = self.children self.emptyChildren() children[0].emptyChildren() x1 = children[0].x1 x2 = children[0].x2 refObjs = [children[0...
[ "def", "flatten", "(", "self", ")", ":", "if", "len", "(", "self", ".", "children", ")", ">", "1", ":", "children", "=", "self", ".", "children", "self", ".", "emptyChildren", "(", ")", "children", "[", "0", "]", ".", "emptyChildren", "(", ")", "x1...
Flattens the tree. The tree become a tree of depth 1 where overlapping regions have been merged together
[ "Flattens", "the", "tree", ".", "The", "tree", "become", "a", "tree", "of", "depth", "1", "where", "overlapping", "regions", "have", "been", "merged", "together" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L269-L300
train
tariqdaouda/pyGeno
pyGeno/tools/SegmentTree.py
SegmentTree.move
def move(self, newX1) : """Moves tree to a new starting position, updates x1s of children""" if self.x1 != None and self.x2 != None : offset = newX1-self.x1 aux_moveTree(offset, self) elif len(self.children) > 0 : offset = newX1-self.children[0].x1 aux_moveTree(offset, self)
python
def move(self, newX1) : """Moves tree to a new starting position, updates x1s of children""" if self.x1 != None and self.x2 != None : offset = newX1-self.x1 aux_moveTree(offset, self) elif len(self.children) > 0 : offset = newX1-self.children[0].x1 aux_moveTree(offset, self)
[ "def", "move", "(", "self", ",", "newX1", ")", ":", "if", "self", ".", "x1", "!=", "None", "and", "self", ".", "x2", "!=", "None", ":", "offset", "=", "newX1", "-", "self", ".", "x1", "aux_moveTree", "(", "offset", ",", "self", ")", "elif", "len"...
Moves tree to a new starting position, updates x1s of children
[ "Moves", "tree", "to", "a", "new", "starting", "position", "updates", "x1s", "of", "children" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/SegmentTree.py#L302-L309
train
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.encode
def encode(self, sequence): """Returns a tuple (binary reprensentation, default sequence, polymorphisms list)""" polymorphisms = [] defaultSequence = '' binSequence = array.array(self.forma.typecode) b = 0 i = 0 trueI = 0 #not inc in case if poly poly = set() while i < len(sequence)-1: b = b | ...
python
def encode(self, sequence): """Returns a tuple (binary reprensentation, default sequence, polymorphisms list)""" polymorphisms = [] defaultSequence = '' binSequence = array.array(self.forma.typecode) b = 0 i = 0 trueI = 0 #not inc in case if poly poly = set() while i < len(sequence)-1: b = b | ...
[ "def", "encode", "(", "self", ",", "sequence", ")", ":", "polymorphisms", "=", "[", "]", "defaultSequence", "=", "''", "binSequence", "=", "array", ".", "array", "(", "self", ".", "forma", ".", "typecode", ")", "b", "=", "0", "i", "=", "0", "trueI", ...
Returns a tuple (binary reprensentation, default sequence, polymorphisms list)
[ "Returns", "a", "tuple", "(", "binary", "reprensentation", "default", "sequence", "polymorphisms", "list", ")" ]
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L21-L61
train
tariqdaouda/pyGeno
pyGeno/tools/BinarySequence.py
BinarySequence.findPolymorphisms
def findPolymorphisms(self, strSeq, strict = False): """ Compares strSeq with self.sequence. If not 'strict', this function ignores the cases of matching heterozygocity (ex: for a given position i, strSeq[i] = A and self.sequence[i] = 'A/G'). If 'strict' it returns all positions where strSeq differs self,sequence...
python
def findPolymorphisms(self, strSeq, strict = False): """ Compares strSeq with self.sequence. If not 'strict', this function ignores the cases of matching heterozygocity (ex: for a given position i, strSeq[i] = A and self.sequence[i] = 'A/G'). If 'strict' it returns all positions where strSeq differs self,sequence...
[ "def", "findPolymorphisms", "(", "self", ",", "strSeq", ",", "strict", "=", "False", ")", ":", "arr", "=", "self", ".", "encode", "(", "strSeq", ")", "[", "0", "]", "res", "=", "[", "]", "if", "not", "strict", ":", "for", "i", "in", "range", "(",...
Compares strSeq with self.sequence. If not 'strict', this function ignores the cases of matching heterozygocity (ex: for a given position i, strSeq[i] = A and self.sequence[i] = 'A/G'). If 'strict' it returns all positions where strSeq differs self,sequence
[ "Compares", "strSeq", "with", "self", ".", "sequence", ".", "If", "not", "strict", "this", "function", "ignores", "the", "cases", "of", "matching", "heterozygocity", "(", "ex", ":", "for", "a", "given", "position", "i", "strSeq", "[", "i", "]", "=", "A",...
474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14
https://github.com/tariqdaouda/pyGeno/blob/474b1250bf78ce5c7e7c3bbbfdbad9635d5a7d14/pyGeno/tools/BinarySequence.py#L75-L94
train