- Name: Sunny Tarawade
- Organisation: EMBL-EBI (European Bioinformatics Institute)
- Organization Project: FAANG (Functional Annotation of ANimal Genomics)
- GSOC Project Title: New FAANG backend with Elasticsearch and GraphQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MAX_FILTER_QUERY_DEPTH = 3 | |
| ANALYSIS = 'analysis' | |
| EXPERIMENT = 'experiment' | |
| SPECIMEN = 'specimen' | |
| ORGANISM = 'organism' | |
| ARTICLE = 'article' | |
| DATASET = 'dataset' | |
| FILE = 'file' | |
| PROTOCOL_ANALYSIS = 'protocol_analysis' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def resolve_single_document(index_name,id,primary_keys): | |
| body = { | |
| "query":{ | |
| "bool":{ | |
| # We append '.keyword' to the key name because otherwise elasticsearch | |
| # returns nothing. Hence we need to either append '.keyword' to key name | |
| # or convert all the values to lower case. This is because these fields | |
| # are not analysed by elasticsearch. | |
| "should":[{"term":{key + '.keyword':id}} for key in primary_keys] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArticleSchema(ObjectType): | |
| article = Field(ArticleNode,id = ID(required=True), alternate_id = ID(required = False)) | |
| # all_article = relay.ConnectionField(ArticleConnection,filter=MyInputObjectType()) | |
| all_articles = relay.ConnectionField(ArticleConnection,filter=ArticleFilter_Argument()) | |
| # just an example of relay.connection field and batch loader | |
| some_articles = relay.ConnectionField(ArticleConnection,ids = List(of_type=String, required=True)) | |
| def resolve_article(root,info,**args): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def resolve_all(index_name,**kwargs): | |
| if index_name in ['derived_from_specimen','derives_specimen_sample']: | |
| index_name = 'specimen' | |
| elif index_name == 'derived_from_organism': | |
| index_name = 'organism' | |
| filter_queries = kwargs['filter'] if 'filter' in kwargs else [] | |
| query = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ''' | |
| # This function takes in a string path and returns a value. | |
| # Eg. e = {'a' : {'b' : {'c' : 'd'}}} | |
| # deep_get(e,'a.b.c') => 'd' | |
| # ''' | |
| def deep_get(dictionary, keys, default=None): | |
| return reduce(lambda d, key: d.get(key, default) if isinstance(d, dict) else default, keys.split("."), dictionary) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_projected_data(left_index,right_index,left_index_data,right_index_data,inner_join = True): | |
| # this is going to be our joined resultant data | |
| res = [] | |
| # There are two types of joins, which I have named Type 1 and Type 2. | |
| # Let's take an example for understanding: | |
| # Analysis : { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def resolve_with_join(filter,left_index): | |
| # check how deep is the query for join. That is if we have a join between more than | |
| # 3 indices then the query is invalid and hence throw an exception | |
| if not is_filter_query_depth_valid(filter): | |
| raise Exception(QUERY_MAX_DEPTH_EXCEEDED) | |
| # if filter object is empty return all the documents of the index | |
| if not bool(filter): |
I liked the way Grokking the coding interview organized problems into learnable patterns. However, the course is expensive and the majority of the time the problems are copy-pasted from leetcode. As the explanations on leetcode are usually just as good, the course really boils down to being a glorified curated list of leetcode problems.
So below I made a list of leetcode problems that are as close to grokking problems as possible.
