Hi everyone,<br><br>To follow up on my previous email, I am sending the script I used, the structure of my table, as well as the querry I use to search in my new table:<br><br>The Script used to create the Table Turn:<br><br>
<br>USE PdBase;<br><br>###############This is the main script which creates the _TURN table#############<br><br>DROP TABLE IF EXISTS `mohaddez_HE`.`_TURNS_tmp_CAN`;<br><br>CREATE TEMPORARY TABLE `mohaddez_HE`.`_TURNS_tmp_CAN`<br>
(<br>SELECT &nbsp;&nbsp;&nbsp; MMS_ENTRY.id AS pdb,<br>&nbsp;&nbsp;&nbsp; STRUCT_CONF.struct_conf_key AS id, <br>&nbsp;&nbsp;&nbsp; STRUCT_CONF.id AS name,<br>&nbsp;&nbsp;&nbsp; ENTITY_POLY.pdbx_seq_one_letter_code_can AS sequence, <br>&nbsp;&nbsp;&nbsp; MMS_ENTRY.entry_key, <br>&nbsp;&nbsp;&nbsp; STRUCT_CONF.beg_label_seq_id AS begin,&nbsp; <br>
&nbsp;&nbsp;&nbsp; STRUCT_CONF.end_label_seq_id AS end, <br>&nbsp;&nbsp;&nbsp; STRUCT_CONF.end_label_seq_id-STRUCT_CONF.beg_label_seq_id+1 AS length,<br>&nbsp;&nbsp;&nbsp; STRUCT_CONF.beg_auth_comp_id AS first_residu,<br>&nbsp;&nbsp;&nbsp; STRUCT_CONF.beg_label_asym_id AS chain <br>
FROM &nbsp;&nbsp;&nbsp; ENTITY_POLY, STRUCT_CONF, MMS_ENTRY, STRUCT_ASYM <br>WHERE <br>&nbsp;&nbsp;&nbsp; MMS_ENTRY.entry_key = ENTITY_POLY.entry_key AND <br>&nbsp;&nbsp;&nbsp; MMS_ENTRY.entry_key = STRUCT_CONF.entry_key AND <br>&nbsp;&nbsp;&nbsp; MMS_ENTRY.entry_key = STRUCT_ASYM.entry_key AND<br>
&nbsp;&nbsp;&nbsp; STRUCT_CONF.conf_type_id = &#39;TURN_P&#39; AND<br>&nbsp;&nbsp;&nbsp; STRUCT_ASYM.id = STRUCT_CONF.beg_label_asym_id AND<br>&nbsp;&nbsp;&nbsp; STRUCT_ASYM.entity_id = ENTITY_POLY.entity_id<br>); <br><br>###########The&nbsp; rest of the script makes modification to the original script########################<br>
<br>UPDATE mohaddez_HE._TURNS_tmp_CAN SET Sequence = REPLACE(Sequence,&#39;\n&#39;,&#39;&#39;);<br>DROP TABLE IF EXISTS `mohaddez_HE`.`_TURNS_tmp_CAN_RESTRICTED`; <br>##############################################################################<br>
######create the new table TURNS_tmp_CAN_RESTRICTED#####<br>Sequence = between Begin and ENd<br>####################################################################################<br><br><br>CREATE TABLE `mohaddez_HE`.`_TURNS_tmp_CAN_RESTRICTED` <br>
(<br>SELECT &nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.pdb,<br>&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.id, <br>&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.name,<br>&nbsp;&nbsp;&nbsp; SUBSTRING( &nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.sequence, <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.begin, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.end - mohaddez_HE._TURNS_tmp_CAN.begin + 1<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;) AS sequence, <br>&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.entry_key, <br>&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.begin,&nbsp; <br>&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.end, <br>
&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.length, <br>&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.first_residu,<br>&nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN.chain<br>FROM &nbsp;&nbsp;&nbsp; mohaddez_HE._TURNS_tmp_CAN&nbsp;&nbsp;&nbsp; <br>);<br>############################################################################################<br>
<br><br><br>DROP TABLE `mohaddez_HE`.`_TURNS_tmp_CAN`;<br>DROP TABLE IF EXISTS `mohaddez_HE`.`_TURN`;<br>RENAME TABLE `mohaddez_HE`.`_TURNS_tmp_CAN_RESTRICTED` TO `mohaddez_HE`.`_TURN`;<br><br>####################################################################################<br>
######changing the types of the fields#####<br>####################################################################################<br>ALTER TABLE `mohaddez_HE`.`_TURN` CHANGE `begin` `begin` SMALLINT NULL DEFAULT NULL; <br>
ALTER TABLE `mohaddez_HE`.`_TURN` CHANGE `end` `end` SMALLINT NULL DEFAULT NULL;<br>ALTER TABLE `mohaddez_HE`.`_TURN` CHANGE `length` `length` SMALLINT NULL DEFAULT NULL;<br>ALTER TABLE `mohaddez_HE`.`_TURN` CHANGE `pdb` `pdb` VARCHAR( 4 ) CHARACTER SET ascii COLLATE ascii_general_ci NOT NULL; <br>
ALTER TABLE `mohaddez_HE`.`_TURN` CHANGE `name` `name` VARCHAR( 11 ) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL; <br>ALTER TABLE `mohaddez_HE`.`_TURN` CHANGE `first_residu` `first_residu` VARCHAR( 3 ) CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL; <br>
ALTER TABLE `mohaddez_HE`.`_TURN` CHANGE `sequence` `sequence` LONGTEXT CHARACTER SET ascii COLLATE ascii_general_ci NULL DEFAULT NULL ;<br>ALTER TABLE `mohaddez_HE`.`_TURN` ADD `is_in_surface` BINARY DEFAULT &#39;0&#39; NOT NULL ;<br>
ALTER TABLE `mohaddez_HE`.`_TURN` ADD `distance_to_surface` FLOAT NOT NULL DEFAULT &#39;0&#39;;<br><br>######################&nbsp;&nbsp;&nbsp; ##############################################################<br>###################order the table by pdb#########################<br>
<br>CREATE TEMPORARY TABLE `mohaddez_HE`.`_TURN_PDB_tmp` AS <br>&nbsp;&nbsp;&nbsp; SELECT &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sequence, GROUP_CONCAT( DISTINCT (pdb) ) AS pdbs, count( * ) AS pdbscount<br>&nbsp;&nbsp;&nbsp; FROM &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; mohaddez_HE._TURN<br>&nbsp;&nbsp;&nbsp; GROUP BY &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; sequence;<br>
ALTER TABLE `mohaddez_HE`.`_TURN_PDB_tmp` ADD INDEX ( `sequence` ( 10 ) ); <br>##########################################################<br>#######<br><br>DROP TABLE IF EXISTS `mohaddez_HE`.`_TURN_WITH_PDBS_tmp`;<br>CREATE TABLE `mohaddez_HE`.`_TURN_WITH_PDBS_tmp`<br>
AS SELECT mohaddez_HE._TURN.*, mohaddez_HE._TURN_PDB_tmp.pdbs, mohaddez_HE._TURN_PDB_tmp.pdbscount AS pdbcount<br>FROM mohaddez_HE._TURN, mohaddez_HE._TURN_PDB_tmp<br>WHERE mohaddez_HE._TURN.sequence=mohaddez_HE._TURN_PDB_tmp.sequence;<br>
<br><br>DROP TABLE IF EXISTS `mohaddez_HE`.`_TURN`; <br>RENAME TABLE `mohaddez_HE`.`_TURN_WITH_PDBS_tmp` TO `mohaddez_HE`.`_TURN`;<br><br>###############################################################################################################################<br>
<br><br>My Turn Table looks like this:<br><br>+---------------------+--------------+------+-----+---------+-------+<br>| Field&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | Null | Key | Default | Extra |<br>+---------------------+--------------+------+-----+---------+-------+<br>
| pdb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs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p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| begin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | smallint(6)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| end&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | smallint(6)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| length&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | smallint(6)&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
| first_residu&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | char(3)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| chain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | varchar(255) | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| is_in_surface&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | binary(1)&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| distance_to_surface | float&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
| pdbs&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | longtext&nbsp;&nbsp;&nbsp;&nbsp; | YES&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | NULL&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>| pdbcount&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | bigint(21)&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; | 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>+---------------------+--------------+------+-----+---------+-------+<br><br>
<br><br>Th Querry: <br>select pdb,id, name, sequence, entry_key, begin, end, length,first_residue, chain from _TURN where pdb =&quot;2pab&quot;;<br>The result:<br><br>+------+--------+---------+----------+-----------+-------+------+--------+--------------+-------+<br>
| pdb&nbsp; | id&nbsp;&nbsp;&nbsp;&nbsp; | name&nbsp;&nbsp;&nbsp; | sequence | entry_key | begin | end&nbsp; | length | first_residu | chain |<br>+------+--------+---------+----------+-----------+-------+------+--------+--------------+-------+<br>| 2pab | 609473 | TURN_P1 | SESG&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; 30320 |&nbsp;&nbsp;&nbsp; 50 |&nbsp;&nbsp; 53 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 | SER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | A&nbsp;&nbsp;&nbsp;&nbsp; |<br>
| 2pab | 609475 | TURN_P2 | SESG&nbsp;&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;&nbsp; 30320 |&nbsp;&nbsp;&nbsp; 50 |&nbsp;&nbsp; 53 |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 | SER&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | C&nbsp;&nbsp;&nbsp;&nbsp; |<br>+------+--------+---------+----------+-----------+-------+------+--------+--------------+-------+<br><br><br>However after I check the pdb site mysql, I have noticed that there are definitely more than 1 turn there: <a href="http://www.rcsb.org/pdb/explore/remediatedSequence.do?structureId=2PAB">http://www.rcsb.org/pdb/explore/remediatedSequence.do?structureId=2PAB</a>. I have found other pdbs will similar problem<br>
<br>Also from the result above it can be observed that both rows are the identical, however this is normal , since there are 2 chains.<br><br><br>I definitely appreciate your help with this, since all my work will be based on this table. I will also investigate the _BETA table to see if I do find similar inconsistencies.<br>
<br>Thank you for your time!<br><br>best regards,<br><br>zia<br><br><br><br><br>