@@ -1727,12 +1727,24 @@ function _proteins()
17271727
17281728 // Only display original UAS approved proteins (not clones which have the same externalId)
17291729 if ($ this ->has_arg ('original ' ) && $ this ->arg ('original ' ) == 1 ) {
1730- $ group = 'pr.externalId ' ;
1731- $ order .= ', pr.bltimeStamp DESC ' ;
1730+ $ where .= ' AND pr.proteintype = "ORIGIN:UAS" ' ;
17321731 }
17331732
17341733 if ($ this ->has_arg ('sort_by ' )) {
1735- $ cols = array ('NAME ' => 'pr.name ' , 'ACRONYM ' => 'pr.acronym ' , 'MOLECULARMASS ' => 'pr.molecularmass ' , 'HASSEQ ' => "CASE WHEN sequence IS NULL THEN 'No' ELSE 'Yes' END " );
1734+ $ cols = array (
1735+ 'NAME ' => 'pr.name ' ,
1736+ 'ACRONYM ' => 'pr.acronym ' ,
1737+ 'MOLECULARMASS ' => 'pr.molecularmass ' ,
1738+ 'DENSITY ' => 'pr.density ' ,
1739+ 'SEQUENCE ' => 'pr.sequence ' ,
1740+ 'SAFETYLEVEL ' => 'pr.safetylevel ' ,
1741+ 'HASSEQ ' => "CASE WHEN sequence IS NULL THEN 'No' ELSE 'Yes' END " ,
1742+ 'PDBS ' => 'pdbs ' ,
1743+ 'CONCENTRATIONTYPE ' => 'concentrationtype ' ,
1744+ 'COMPONENTTYPE ' => 'componenttype ' ,
1745+ 'DCOUNT ' => 'dcount ' ,
1746+ 'SCOUNT ' => 'scount '
1747+ );
17361748 $ dir = $ this ->has_arg ('order ' ) ? ($ this ->arg ('order ' ) == 'asc ' ? 'ASC ' : 'DESC ' ) : 'ASC ' ;
17371749 if (array_key_exists ($ this ->arg ('sort_by ' ), $ cols ))
17381750 $ order = $ cols [$ this ->arg ('sort_by ' )] . ' ' . $ dir ;
@@ -1748,56 +1760,23 @@ function _proteins()
17481760 HEX(pr.externalid) as externalid,
17491761 pr.density,
17501762 count(php.proteinid) as pdbs,
1751- pr.safetylevel
1763+ pr.safetylevel,
1764+ count(dc.datacollectionid) as dcount,
1765+ count(b.blsampleid) as scount
17521766
17531767 FROM protein pr
17541768 LEFT OUTER JOIN concentrationtype ct ON ct.concentrationtypeid = pr.concentrationtypeid
17551769 LEFT OUTER JOIN componenttype cmt ON cmt.componenttypeid = pr.componenttypeid
17561770 LEFT OUTER JOIN protein_has_pdb php ON php.proteinid = pr.proteinid
1757- /* LEFT OUTER JOIN crystal cr ON cr.proteinid = pr.proteinid
1771+ LEFT OUTER JOIN crystal cr ON cr.proteinid = pr.proteinid
17581772 LEFT OUTER JOIN blsample b ON b.crystalid = cr.crystalid
1759- LEFT OUTER JOIN datacollection dc ON b.blsampleid = dc.blsampleid*/
1773+ LEFT OUTER JOIN datacollection dc ON b.blsampleid = dc.blsampleid
17601774 INNER JOIN proposal p ON p.proposalid = pr.proposalid
17611775 $ join
17621776 WHERE $ where
17631777 GROUP BY $ group
17641778 ORDER BY $ order " , $ args );
17651779
1766- $ ids = array ();
1767- $ wcs = array ();
1768- foreach ($ rows as $ r ) {
1769- array_push ($ ids , $ r ['PROTEINID ' ]);
1770- array_push ($ wcs , 'pr.proteinid=: ' . sizeof ($ ids ));
1771- }
1772-
1773- $ dcs = array ();
1774- $ scs = array ();
1775-
1776- if (sizeof ($ ids )) {
1777- $ dcst = $ this ->db ->pq ('SELECT pr.proteinid, count(dc.datacollectionid) as dcount FROM datacollection dc INNER JOIN blsample s ON s.blsampleid=dc.blsampleid INNER JOIN crystal cr ON cr.crystalid = s.crystalid INNER JOIN protein pr ON pr.proteinid = cr.proteinid WHERE ' . implode (' OR ' , $ wcs ) . ' GROUP BY pr.proteinid ' , $ ids );
1778-
1779-
1780- foreach ($ dcst as $ d ) {
1781- $ dcs [$ d ['PROTEINID ' ]] = $ d ['DCOUNT ' ];
1782- }
1783-
1784- $ scst = $ this ->db ->pq ('SELECT pr.proteinid, count(s.blsampleid) as scount FROM blsample s INNER JOIN crystal cr ON cr.crystalid = s.crystalid INNER JOIN protein pr ON pr.proteinid = cr.proteinid WHERE ' . implode (' OR ' , $ wcs ) . ' GROUP BY pr.proteinid ' , $ ids );
1785-
1786- foreach ($ scst as $ d ) {
1787- $ scs [$ d ['PROTEINID ' ]] = $ d ['SCOUNT ' ];
1788- }
1789- }
1790-
1791- foreach ($ rows as &$ r ) {
1792- $ dcount = array_key_exists ($ r ['PROTEINID ' ], $ dcs ) ? $ dcs [$ r ['PROTEINID ' ]] : 0 ;
1793- $ r ['DCOUNT ' ] = $ dcount ;
1794- $ scount = array_key_exists ($ r ['PROTEINID ' ], $ scs ) ? $ scs [$ r ['PROTEINID ' ]] : 0 ;
1795- $ r ['SCOUNT ' ] = $ scount ;
1796-
1797- if ($ this ->has_arg ('pid ' ))
1798- $ r ['SEQUENCE ' ] = $ this ->db ->read ($ r ['SEQUENCE ' ]);
1799- }
1800-
18011780 if ($ this ->has_arg ('pid ' )) {
18021781 if (sizeof ($ rows ))
18031782 $ this ->_output ($ rows [0 ]);
0 commit comments