sql 修复Image_Metadata_Well,_Row,_Col,因为LUAD板已旋转

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 修复Image_Metadata_Well,_Row,_Col,因为LUAD板已旋转相关的知识,希望对你有一定的参考价值。

-- create a copy of the Per_Image table
CREATE TABLE analysis_2015_03_13_Per_Image_fixedrotation LIKE analysis_2015_03_13_Per_Image; 
INSERT analysis_2015_03_13_Per_Image_fixedrotation SELECT * FROM analysis_2015_03_13_Per_Image;

-- add columns
alter table analysis_2015_03_13_Per_Image_fixedrotation 
add x_oldWell varchar(3),
add x_oldRow text,
add x_oldCol text,
add x_newWell varchar(3),
add x_newRow text,
add x_newCol text;

-- Rotate the plate. The queries below do the following:
--  Separate the single-char row and 2-digit col
--  Convert the row to an ASCII number
--  Offset both around the middle value, negates it, and offsets back by the same amt
--  Convert the new row value from ASCII back to char. 
-- Note:
--  The 12.5 offset for the cols is the midpoint between col 01 and 24, i.e, (1 + 24)/2. 
--  Likewise, the 104.5 offset for the rows is the midpoint between ASCII('a') = 97 
--  and ASCII('p') = 112, i.e, (97+112)/2

update analysis_2015_03_13_Per_Image_fixedrotation
set x_newCol = LPAD(-(SUBSTRING(image_metadata_well,2,2)-12.5)+12.5,2,'0');

update analysis_2015_03_13_Per_Image_fixedrotation
set x_newRow = CHAR(-(ASCII(SUBSTRING(image_metadata_well,1,1))-104.5)+104.5);

update analysis_2015_03_13_Per_Image_fixedrotation
set x_newWell = concat(x_newRow, x_newCol);

-- Save the old values
update analysis_2015_03_13_Per_Image_fixedrotation
set x_oldCol = Image_Metadata_Col;

update analysis_2015_03_13_Per_Image_fixedrotation
set x_oldRow = Image_Metadata_Row;

update analysis_2015_03_13_Per_Image_fixedrotation
set x_oldWell = Image_Metadata_Well;

-- Update
update analysis_2015_03_13_Per_Image_fixedrotation
set Image_Metadata_Col = x_newCol;

update analysis_2015_03_13_Per_Image_fixedrotation
set Image_Metadata_Row = x_newRow;

update analysis_2015_03_13_Per_Image_fixedrotation
set Image_Metadata_Well = x_newWell;

-- drop columns
alter TABLE analysis_2015_03_13_Per_Image_fixedrotation
drop x_newCol,
drop x_newRow,
drop x_newWell;

-- upload metadata
# Set barcode (i.e, plate) and well as int/char for unique indexing
CREATE TABLE combined_plate_maps (
PlateName varchar(15),
Row text,
Col text,
Well varchar(3), 
Name text,
PublicID text, 
Vector text,
Transcript text,
Symbol text,
x_mutation_status text,
NCBIGeneID text,
OtherDescriptions text,
InsertLength text,
pert_type text);

-- Load the data
LOAD DATA INFILE '/imaging/analysis/2014_09_09_LUAD_MeyersonLab_AliceBerger_DFCI/2015_03_13/metadata/combined_platemaps_AHB_20150506_ssedits.csv' INTO TABLE combined_plate_maps FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;
SHOW WARNINGS;

-- Create the index
ALTER TABLE combined_plate_maps ADD FULLTEXT INDEX idx (PlateName,Well);

UPDATE analysis_2015_03_13_Per_Image_fixedrotation AS A, combined_plate_maps AS B 
SET 
A.Image_Metadata_Name = B.Name,
A.Image_Metadata_PublicID = B.PublicID, 
A.Image_Metadata_Vector = B.Vector,
A.Image_Metadata_Transcript = B.Transcript,
A.Image_Metadata_Symbol = B.Symbol,
A.Image_Metadata_x_mutation_status = B.x_mutation_status,
A.Image_Metadata_NCBIGeneID = B.NCBIGeneID,
A.Image_Metadata_OtherDescriptions = B.OtherDescriptions,
A.Image_Metadata_InsertLength = B.InsertLength,
A.Image_Metadata_pert_type = B.pert_type
WHERE
A.Image_Metadata_VirusPlateName = B.PlateName AND A.Image_Metadata_Well = B.Well; 

-- No errors; 61056 rows affected, taking 138 s

-- Create index on new table
ALTER TABLE analysis_2015_03_13_Per_Image_fixedrotation 
ADD INDEX idx_barcode_well (Image_Metadata_Barcode(200), Image_Metadata_Well)
-- No errors; 62208 rows affected, taking 7 min
-- Create index on old table so that comparisons are easy
ALTER TABLE analysis_2015_03_13_Per_Image ADD INDEX idx_barcode_well (Image_Metadata_Barcode(200), Image_Metadata_Well)
-- No errors; 62208 rows affected, taking 8 min

-- Verify that the metadata are different
select A.Image_Metadata_PlateName, A.Image_Metadata_Well, A.Image_Metadata_x_mutation_status, B.Image_Metadata_x_mutation_status 
from analysis_2015_03_13_Per_Image as A 
inner join analysis_2015_03_13_Per_Image_fixedrotation as B 
using (Image_Metadata_PlateName, Image_Metadata_Well) 
limit 10

-- Verify that the metadata are different
select 
A.ImageNumber, B.ImageNumber, 
A.Image_Metadata_PlateName, B.Image_Metadata_PlateName, 
A.Image_Metadata_Well, B.Image_Metadata_Well, 
A.Image_Metadata_x_mutation_status, B.Image_Metadata_x_mutation_status, 
A. Image_FileName_OrigAGP, B.Image_FileName_OrigAGP
from 
(select * from analysis_2015_03_13_Per_Image where Image_Metadata_Well = "m18" and Image_Metadata_Barcode = "au00070616") 
as A 
inner join 
(select * from analysis_2015_03_13_Per_Image_fixedrotation where Image_Metadata_Well = "m18" and Image_Metadata_Barcode = "au00070616") 
as B 
using (Image_Metadata_Barcode, Image_Metadata_Well) 
limit 10

-- "ImageNumber","ImageNumber","Image_Metadata_PlateName","Image_Metadata_PlateName","Image_Metadata_Well","Image_Metadata_Well","Image_Metadata_x_mutation_status","Image_Metadata_x_mutation_status","Image_FileName_OrigAGP","Image_FileName_OrigAGP"
-- 30394,28351,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s1_w45a44be04-879c-4e30-bd42-45275a870187.tif"
-- 30394,28356,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s6_w4ecf571a3-2659-4b9d-ab59-bec4835b4ee4.tif"
-- 30394,28357,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s7_w4b5520ca2-7d4e-41c4-9465-1be89c821e96.tif"
-- 30394,28352,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s2_w453da86b6-5902-493d-b9e8-ce8fb43f9fb7.tif"
-- 30394,28358,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s8_w45054a5d2-d3d0-4d79-a38e-1fd88c408440.tif"
-- 30394,28359,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s9_w4f5614ba9-e8fc-45a3-a2fa-3d67dfc6f357.tif"
-- 30394,28354,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s4_w4e08b16bf-8ca1-4c87-bfec-a0d0084af94b.tif"
-- 30394,28353,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s3_w4185d9987-bf4d-45ea-8447-b9ee56d62df9.tif"
-- 30394,28355,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s1_w4e58413c7-37f9-4446-97dd-5350c275c363.tif","7149-01 berger 3-11-13_d07_s5_w4f57e6e25-1309-46f9-ae0e-703c11e33930.tif"
-- 30400,28351,"15_A549_CP_DOC49","15_A549_CP_DOC49","m18","m18","TP53_WT.c","TP53_WT.c","7149-01 berger 3-11-13_m18_s7_w4e50613e1-dfe4-4a5b-a116-06a2bfe40d73.tif","7149-01 berger 3-11-13_d07_s1_w45a44be04-879c-4e30-bd42-45275a870187.tif"

以上是关于sql 修复Image_Metadata_Well,_Row,_Col,因为LUAD板已旋转的主要内容,如果未能解决你的问题,请参考以下文章

如何修复SQL注入漏洞

13sql注入修复

SQL数据库修复/数据库置疑修复

修复SQL2000数据库置疑时出现的错误

如何修复 SQL 数据库置疑

sql注入漏洞如何修复