a ab?g;(@sdddddZddZddZd d Zd d Zd dZddZddZddZd0ddZ d1ddZ d2ddZ dd Z d!d"Z d#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/S)3i3)ZhumanZmouseZpigZratcCsdddd|iidS)N query_stringquery)fromsizer)rr r A/home/cmiss/Jenkins/workspace/SPARC-API/app/scicrunch_requests.pycreate_query_string sr cCsddd|iiiS)Nrterm item.curier )doir r r create_doi_querys rcCsddd|iidS)Ntermsrr rr )doisr r r create_multiple_doi_query!s rcCsddd|iidS)Nrrpennsieve.identifierrr )idsr r r create_multiple_discoverId_query,s rcCs^|d}g}|D]}|ddd|Dqdd|D}ddd d gd |d id S)N css|]}|r|VqdSN)isalnum).0er r r ;z%create_title_query..cSsg|]}|rd|dqS)()r )rpr r r =r z&create_title_query.. rrz item.name AND fieldsrr rr)splitappendjoin)titlepartsZalphanum_partsr#rr r r create_title_query7s r/cCsddddd|iiigddS)Nrmatchrr)ZanatomyrZ organisms)r rr_sourcer  identifierr r r create_anatomy_queryLsr5cCs0|d}d|d}ddddg|did S) N:*r0r%rrz *identifierr'r))r*)r4r.rr r r create_identifier_query_s r8cCsddd|iiiS)Nrr zpennsieve.identifier.aggregater r3r r r !create_pennsieve_identifier_queryqs r9r%rcCs||d|g|didS)Nrr'r)r )fieldZ search_termr from_r r r create_field_query{sr<iricCs(dddddd|d|iiigiidS) Nr%rboolmustZ match_phrasez existing_ids.rr)r )r Zexisting_id_typer r r create_onto_term_querysr@c Cs.dddd|ddddiiigddid iid S) Nrr compositecurierr:zitem.curie.aggregater)r sourcesafterrr aggregationsr )r r r r create_doi_aggregates rHcCs&dddiiggdd|iidii}|S)Nrr>Z match_allitemrC)r?Zshouldfilterr )rrr r r create_doi_requestsrKcCs dddgd|ddii}|S)Nrrz*mimetype.name"r'r )Zmimetype_queryrr r r create_multiple_mimetype_querys  rMc Cs4dd|dddddiddigd iid }t|fS) Nrrr_countdesc_keyasc)r:r orderrF)get_facet_type_map)type_datar r r create_facet_querys rWcCsf|dur d}|durd}|s.|s.|s.||dS||dddiid}t|||t}||ddd<|S)Nr%r)r rrrrr))facet_query_stringrT)rrfacetsr startrVqsr r r create_filter_requests    r\cCs|rt|dSdSr)BODY_SCAFFOLD_DATASETgetlower)speciesr r r get_body_scaffold_dataset_id srac Cs:gdgddgdgdgdgdgdgdgdgdgdgd S)N)z(organisms.primary.species.name.aggregatez'organisms.sample.species.name.aggregatez)organisms.scaffold.species.name.aggregatezattributes.subject.sex.valuezanatomy.organ.name.aggregatezitem.modalities.keywordz$attributes.subject.ageCategory.value) r`ZSpeciesZgenderZGendersexZSexZgenotypezAnatomical structureorganZOrganzExperimental approachzAge categoriesr r r r r rTsrTc Csi}t|D]n\}}|dus ||dus d||vs d||vrLq q ||vrh||g||<q ||||q d}|dkrd|d}|dkrt|dkr|d7}|D](}|dkr8|st|d kot||d k} | r|d7}||D].} | d kr|d 7}| ||d ur|d 7}q| r|d7}n|d7}||D]p} || d7}||D]:} |d| d7}| ||d ur|d 7}n|d7}q`| ||d urH|d 7}qH|d7}|t|d ur|d7}q|S)Nshowallrr!r"rr&datasetsr0Z scaffoldszOobjects.additional_mimetype.name:(application%2fx.vnd.abi.scaffold.meta%2Bjson) OR z:() enumerater_keysr+lenlist) rrrYtype_maptir ZqtkZneedParentheseslmr r r rX#sL4                rXcCsdddddddddiid }t|dkrd d d gii}d }|D](}||dkrZ|d7}|d|d7}qB||d d<||d<|S)NrZnames_and_curiesrZpainlesszdef a=null;if(params['_source']['anatomy'] != null ) { if(params['_source']['anatomy']['organ'] != null ) { a = params['_source']['anatomy']['organ'];}} return a;)langinlinerN)scriptr rFrr(z *species.namerrhr!r"r)rk)r`bodyrrrIr r r create_request_body_for_curies[s6   rwN)r%r)r=)rA)r]r rrrr/r5r8r9r<r@rHrKrMrWr\rarTrXrwr r r r s.       8