<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Dear Antanas,<div class=""><br class=""></div><div class="">Thanks you very much for the detailed instructions! I tried both of your mysql regular expression and RESTful API solutions. They works perfect!</div><div class=""><br class=""><div class="">
<div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div style="color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Thanks a lot for your help. I really appreciate it. Have a nice holiday!</div><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br class="">Best Regards,<br class=""></div><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br class=""></div><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Long</div></div></div></div></div></div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Dec 30, 2018, at 4:27 PM, Antanas Vaitkus <<a href="mailto:antanas.vaitkus90@gmail.com" class="">antanas.vaitkus90@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class="">Dear Long Yang,<br class=""><br class=""></div>the MySQL LIKE operator allows one to specify wildcard values using the "%" symbol (<a href="https://dev.mysql.com/doc/refman/8.0/en/pattern-matching.html" class="">https://dev.mysql.com/doc/refman/8.0/en/pattern-matching.html</a>).<br class=""></div><div class="">For example, Your query could be rewritten as:<br class=""> '<b class="">SELECT file FROM data WHERE formula RLIKE "- C%Ca%O%-" and nel=3'</b></div><div class=""><b class=""><br class=""></b></div><div class="">It works on this specific case, however, it is not entirely correct since structures containing only C, Ca and Os would also be selected if there were any in the COD. This is due to the '%' symbol matching any number of characters.<br class=""></div><div class=""><b class=""></b></div><div class=""><br class="">One could alternatively employ the RLIKE operator that allows using regular expressions (<a href="https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp" class="">https://dev.mysql.com/doc/refman/8.0/en/regexp.html#operator_regexp</a>). It is a bit more complex, but definitely more flexible.<br class=""><br class=""></div><div class="">For example, a query that selects all structures that consists only of C, Ca and O would read:<br class=""><br class="">mysql -u cod_reader -h <a href="http://www.crystallography.net/" target="_blank" class="">www.crystallography.net</a> -e '<b class="">SELECT file FROM data WHERE formula RLIKE "C[0-9.]* Ca[0-9.]* O[0-9.]*" and nel=3</b>' cod</div><br class=""></div><div class="">The '<b class="">[0-9.]*</b>' sequence after each chemical element specifies that it is allowed for the chemical element name to be followed by a floating-point number. In cases when one need structures with specific stoichiometry the sequence can be replaced by an exact number, i.e. ... RLIKE "C5 " would return all structures that have 5 carbon atoms in their chemical formula.<br class=""><br class=""></div><div class=""><b class="">Please note, that the order of chemical symbols in Your query is important -- formulas in the COD follow the Hill formula notation </b>(<a href="https://en.wikipedia.org/wiki/Chemical_formula#Hill_system" class="">https://en.wikipedia.org/wiki/Chemical_formula#Hill_system</a>) <b class="">and moving the query element into different positions would most likely not return any results </b>( i.e. RLIKE "<b class="">C[0-9.]* Ca<b class="">[0-9.]*</b></b>" is a proper query whereas <b class=""><b class="">"<b class="">Ca<b class="">[0-9.]*<b class=""><b class=""><b class=""> C[0-9.]*</b></b></b></b></b>"</b></b>is not).<b class=""> </b></div><div class=""><br class=""></div><div class="">The restful API is also a viable option, however, I must admit that are current examples of the RESTful API usage are currently a bit lacking -- we will work on that. Some general tips on how to use it can be found on the following GitHub discussion page (<a href="https://github.com/cod-developers/cod-tools/issues/3" class="">https://github.com/cod-developers/cod-tools/issues/3</a>). <br class=""></div><div class=""><br class=""></div><div class="">I also crafted a simple example tailored to Your specific query (C, Ca, O):</div><div class=""><br class=""></div><div class=""><a href="http://www.crystallography.net/cod/result.php?el1=C&el2=Ca&el3=O&strictmax=3&format=lst" class=""><i class="">http://www.crystallography.net/cod/result.php?el1=C&el2=Ca&el3=O&strictmax=3&format=lst</i></a><br class=""></div><div class=""><br class=""></div><div class="">Pasting this URL to Your browser or querying it using alternative web clients like cURL would return an ID list of COD entries matching the given criteria, i.e.:<br class=""><i class=""><br class="">curl -s '<a href="http://www.crystallography.net/cod/result.php?el1=C&el2=Ca&el3=O&strictmax=3&format=lst" class="">http://www.crystallography.net/cod/result.php?el1=C&el2=Ca&el3=O&strictmax=3&format=lst</a>'</i><br class=""><br class=""></div><div class="">If You have any more questions please do not hesitate to ask, but note, that I might be a bit slower to respond due to the New Year being around the corner.<br class=""><br class=""></div><div class="">Sincerely,<br class=""></div><div class="">Antanas Vaitkus<br class=""></div><div class=""><b class=""><br class=""></b></div><div dir="ltr" class=""><div class=""><br class=""></div></div></div></div></div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sun, 30 Dec 2018 at 22:25, Long Yang <<a href="mailto:long.yang@columbia.edu" class="">long.yang@columbia.edu</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;" class="">Dear Antanas,<div class=""><br class=""></div><div class="">Thanks a lot for your quick reply! Could you please show in more details about how to do it in MySQL level? Sorry I was a beginner of SQL.</div><div class=""><br class=""></div><div class="">For example, I would like to query all entries only with elements “Ca”, “C”, “O”, what would the MySQL query like?</div><div class=""><br class=""></div><div class="">I tried the query below but it doesn’t work.</div><div class="">mysql -u cod_reader -h <a href="http://www.crystallography.net/" target="_blank" class="">www.crystallography.net</a> -e '<b class="">select file from data where formula like "- C Ca O -“ and nel=3</b>' cod</div><div class=""><br class=""></div><div class="">BTW, how about using RESTful API, it seems to have the “el1, el2, ..., el8” and “strictmin, strictmax” parameters according to the wiki doc. But I don’t know how to use it.</div><div class=""><br class=""></div><div class=""><div class="">
<div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><div style="overflow-wrap: break-word;" class="">Thank you!</div><div style="overflow-wrap: break-word;" class=""><div style="overflow-wrap: break-word;" class=""><br class="">Best Regards,<br class=""></div><div style="overflow-wrap: break-word;" class=""><br class=""></div><div style="overflow-wrap: break-word;" class="">Long</div></div></div></div></div></div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 30, 2018, at 3:08 PM, Antanas Vaitkus <<a href="mailto:antanas.vaitkus90@gmail.com" target="_blank" class="">antanas.vaitkus90@gmail.com</a>> wrote:</div><br class="gmail-m_5747548181321117675Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div class="">Dear Long Yang,<br class=""><br class=""></div>the specific elements are only listed in the chemical formula fields ('formula', 'calcformula', 'cellformula'). The formula fields all follow the same format:<br class=""></div>"- el1[no1] el2[no2] el3[no3] -", for example, "- F16 H3 O6 Sr5 V3 -".<br class=""><br class=""></div><div class="">On a pure MySQL level You can use the "LIKE" or "RLIKE" operators to construct the appropriate queries.<br class=""><br class=""></div><div class="">Hope that helps.<br class=""><br class=""></div><div class="">Sincerely,<br class=""></div><div class="">Antanas Vaitkus<br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Sun, 30 Dec 2018 at 21:59, Long Yang <<a href="mailto:long.yang@columbia.edu" target="_blank" class="">long.yang@columbia.edu</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="">Hi,<div class=""><br class=""></div><div class="">I am Long Yang, graduate student from Columbia University, USA. I am trying to query COD by specifying elements. It works as expected on your website, by entering the elements, for example, “Ca”, “C”, “O”. But when I do the SQL query, it doesn’t have similar schema as search in the website. The schema (<a href="http://wiki.crystallography.net/cod_mysql_schema/" target="_blank" class="">http://wiki.crystallography.net/cod_mysql_schema/</a>) only have “ nel” to specify the number of elements, but does not have “elements” thing to enter “Ca”, “C”, “O”. How to do it?</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">Thank you!</div><div class=""><div class=""><br class="">Best Regards,<br class=""></div><div class=""><br class=""></div><div class="">Long</div></div></div></div></div></div></div></div></div>_______________________________________________<br class="">
Cod-bugs mailing list<br class="">
<a href="mailto:Cod-bugs@lists.crystallography.net" target="_blank" class="">Cod-bugs@lists.crystallography.net</a><br class="">
<a href="http://lists.crystallography.net/cgi-bin/mailman/listinfo/cod-bugs" rel="noreferrer" target="_blank" class="">http://lists.crystallography.net/cgi-bin/mailman/listinfo/cod-bugs</a><br class="">
</blockquote></div><br clear="all" class=""><br class="">-- <br class=""><div dir="ltr" class="gmail-m_5747548181321117675gmail_signature"><div dir="ltr" class=""><div class=""><div class="">Antanas Vaitkus,<br class=""></div>PhD student at Vilnius University Institute of Biotechnology,<br class=""><span class=""><span class=""><span class="">room V325, </span></span></span>Saulėtekio al. 7,<br class="">LT-10257 Vilnius, Lithuania<br class=""></div><div class=""><div class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><br class=""><br class=""></div></div></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></div></blockquote></div><br clear="all" class=""><br class="">-- <br class=""><div dir="ltr" class="gmail_signature"><div dir="ltr" class=""><div class=""><div class="">Antanas Vaitkus,<br class=""></div>PhD student at Vilnius University Institute of Biotechnology,<br class=""><span class=""><span class=""><span class="">room V325, </span></span></span>Saulėtekio al. 7,<br class="">LT-10257 Vilnius, Lithuania<br class=""></div><div class=""><div class=""><div class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><br class=""><br class=""></div></div></div></div></div></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>