From 442dc25fd72433abb5d0c72c76a088cbd02f50e5 Mon Sep 17 00:00:00 2001 From: Stephen Inglis Date: Wed, 9 Sep 2020 10:09:36 +0100 Subject: [PATCH 1/3] Added tag2 information to pac_bio_run table. --- .../20200909085557_add_tag2_to_pac_bio_run.rb | 10 ++++++ db/structure.sql | 32 +++++++++++-------- spec/models/pac_bio_run_spec.rb | 8 +++++ 3 files changed, 37 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb diff --git a/db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb b/db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb new file mode 100644 index 00000000..362b01ce --- /dev/null +++ b/db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb @@ -0,0 +1,10 @@ +class AddTag2ToPacBioRun < ActiveRecord::Migration + def change + change_table :pac_bio_run do |t| + t.string 'tag2_sequence', limit: 30, comment: 'Tag sequence for tag 2', after: :tag_set_name + t.string 'tag2_set_id_lims', limit: 20, comment: 'LIMs-specific identifier of the tag set for tag 2', after: :tag2_sequence + t.string 'tag2_set_name', limit: 100, comment: 'WTSI-wide tag set name for tag 2', after: :tag2_set_id_lims + t.string 'tag2_identifier', limit: 30, comment: 'The position of tag2 within the tag group', after: :tag2_set_name + end + end +end diff --git a/db/structure.sql b/db/structure.sql index db1e1e9a..fdc5b239 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,6 +1,6 @@ --- MySQL dump 10.13 Distrib 8.0.19, for osx10.15 (x86_64) +-- MySQL dump 10.13 Distrib 8.0.19, for osx10.14 (x86_64) -- --- Host: localhost Database: unified_warehouse_development +-- Host: localhost Database: unified_warehouse_test -- ------------------------------------------------------ -- Server version 8.0.19 @@ -44,7 +44,7 @@ CREATE TABLE `bmap_flowcell` ( KEY `fk_bmap_flowcell_to_study` (`id_study_tmp`), CONSTRAINT `fk_bmap_flowcell_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_bmap_flowcell_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -77,7 +77,7 @@ CREATE TABLE `flgen_plate` ( KEY `flgen_plate_study_fk` (`id_study_tmp`), CONSTRAINT `flgen_plate_sample_fk` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`), CONSTRAINT `flgen_plate_study_fk` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -144,7 +144,7 @@ CREATE TABLE `iseq_flowcell` ( KEY `index_iseq_flowcell_legacy_library_id` (`legacy_library_id`), CONSTRAINT `iseq_flowcell_sample_fk` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`), CONSTRAINT `iseq_flowcell_study_fk` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=277 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -181,7 +181,7 @@ CREATE TABLE `oseq_flowcell` ( KEY `fk_oseq_flowcell_to_study` (`id_study_tmp`), CONSTRAINT `fk_oseq_flowcell_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_oseq_flowcell_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -205,6 +205,10 @@ CREATE TABLE `pac_bio_run` ( `tag_sequence` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Tag sequence for tag', `tag_set_id_lims` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'LIMs-specific identifier of the tag set for tag', `tag_set_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'WTSI-wide tag set name for tag', + `tag2_sequence` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Tag sequence for tag 2', + `tag2_set_id_lims` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'LIMs-specific identifier of the tag set for tag 2', + `tag2_set_name` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'WTSI-wide tag set name for tag 2', + `tag2_identifier` varchar(30) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'The position of tag2 within the tag group', `plate_barcode` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The human readable barcode for the plate loaded onto the machine', `plate_uuid_lims` varchar(36) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The plate uuid', `well_label` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'The well identifier for the plate, A1-H12', @@ -220,7 +224,7 @@ CREATE TABLE `pac_bio_run` ( KEY `fk_pac_bio_run_to_study` (`id_study_tmp`), CONSTRAINT `fk_pac_bio_run_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_pac_bio_run_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=115 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -251,7 +255,7 @@ CREATE TABLE `qc_result` ( KEY `lookup_index` (`id_qc_result_lims`,`id_lims`), KEY `qc_result_id_library_lims_index` (`id_library_lims`), CONSTRAINT `fk_qc_result_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=79 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -301,7 +305,7 @@ CREATE TABLE `sample` ( UNIQUE KEY `sample_uuid_sample_lims_index` (`uuid_sample_lims`), KEY `sample_accession_number_index` (`accession_number`), KEY `sample_name_index` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=990 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -352,7 +356,7 @@ CREATE TABLE `stock_resource` ( KEY `composition_lookup_index` (`id_stock_resource_lims`,`id_sample_tmp`,`id_lims`), CONSTRAINT `fk_stock_resource_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_stock_resource_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=175 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -408,7 +412,7 @@ CREATE TABLE `study` ( UNIQUE KEY `study_uuid_study_lims_index` (`uuid_study_lims`), KEY `study_accession_number_index` (`accession_number`), KEY `study_name_index` (`name`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=957 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -429,7 +433,7 @@ CREATE TABLE `study_users` ( PRIMARY KEY (`id_study_users_tmp`), KEY `study_users_study_fk` (`id_study_tmp`), CONSTRAINT `study_users_study_fk` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB AUTO_INCREMENT=265 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -441,7 +445,7 @@ CREATE TABLE `study_users` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-05-18 11:09:26 +-- Dump completed on 2020-09-09 10:08:31 INSERT INTO schema_migrations (version) VALUES ('20141113110635'); INSERT INTO schema_migrations (version) VALUES ('20141113130813'); @@ -538,3 +542,5 @@ INSERT INTO schema_migrations (version) VALUES ('20200512152113'); INSERT INTO schema_migrations (version) VALUES ('20200518083730'); +INSERT INTO schema_migrations (version) VALUES ('20200909085557'); + diff --git a/spec/models/pac_bio_run_spec.rb b/spec/models/pac_bio_run_spec.rb index 8e6d2b84..4be68a81 100644 --- a/spec/models/pac_bio_run_spec.rb +++ b/spec/models/pac_bio_run_spec.rb @@ -46,6 +46,10 @@ "cost_code" => "cost_code1", "tag_set_name" => "Sanger_168tags - 10 mer tags", "study_uuid" => '000000-0000-0000-0000-0000000001', + 'tag2_identifier' => '1', + 'tag2_sequence' => 'GTCA', + 'tag2_set_id_lims' => '2', + 'tag2_set_name' => 'tag_set_2' }, { "sample_uuid" => '000000-0000-0000-0000-0000000000', @@ -58,6 +62,10 @@ "cost_code" => "cost_code1", "tag_set_name" => "Sanger_168tags - 10 mer tags", "study_uuid" => '000000-0000-0000-0000-0000000001', + 'tag2_identifier' => '1', + 'tag2_sequence' => 'GTCA', + 'tag2_set_id_lims' => '2', + 'tag2_set_name' => 'tag_set_2' } ] }, From 857af779543ae1d843edb41319f540ee35f44c60 Mon Sep 17 00:00:00 2001 From: Stephen Inglis Date: Wed, 9 Sep 2020 10:16:49 +0100 Subject: [PATCH 2/3] rubocopped. --- db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb b/db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb index 362b01ce..ea6282e0 100644 --- a/db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb +++ b/db/migrate/20200909085557_add_tag2_to_pac_bio_run.rb @@ -1,10 +1,13 @@ +# frozen_string_literal: true + +# Add tag2 information to the pac_bio_run table so we can do dual indexing class AddTag2ToPacBioRun < ActiveRecord::Migration def change - change_table :pac_bio_run do |t| + change_table :pac_bio_run, bulk: true do |t| t.string 'tag2_sequence', limit: 30, comment: 'Tag sequence for tag 2', after: :tag_set_name t.string 'tag2_set_id_lims', limit: 20, comment: 'LIMs-specific identifier of the tag set for tag 2', after: :tag2_sequence t.string 'tag2_set_name', limit: 100, comment: 'WTSI-wide tag set name for tag 2', after: :tag2_set_id_lims - t.string 'tag2_identifier', limit: 30, comment: 'The position of tag2 within the tag group', after: :tag2_set_name + t.string 'tag2_identifier', limit: 30, comment: 'The position of tag2 within the tag group', after: :tag2_set_name end end end From b34425dc315a9794f4a1b165c358f213cf77ad58 Mon Sep 17 00:00:00 2001 From: Stephen Inglis Date: Thu, 10 Sep 2020 10:16:03 +0100 Subject: [PATCH 3/3] Updated migration to remove auto increments. --- db/structure.sql | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/db/structure.sql b/db/structure.sql index fdc5b239..82bdced4 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -1,6 +1,6 @@ -- MySQL dump 10.13 Distrib 8.0.19, for osx10.14 (x86_64) -- --- Host: localhost Database: unified_warehouse_test +-- Host: localhost Database: unified_warehouse_development -- ------------------------------------------------------ -- Server version 8.0.19 @@ -44,7 +44,7 @@ CREATE TABLE `bmap_flowcell` ( KEY `fk_bmap_flowcell_to_study` (`id_study_tmp`), CONSTRAINT `fk_bmap_flowcell_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_bmap_flowcell_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -77,7 +77,7 @@ CREATE TABLE `flgen_plate` ( KEY `flgen_plate_study_fk` (`id_study_tmp`), CONSTRAINT `flgen_plate_sample_fk` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`), CONSTRAINT `flgen_plate_study_fk` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) -) ENGINE=InnoDB AUTO_INCREMENT=157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -144,7 +144,7 @@ CREATE TABLE `iseq_flowcell` ( KEY `index_iseq_flowcell_legacy_library_id` (`legacy_library_id`), CONSTRAINT `iseq_flowcell_sample_fk` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`), CONSTRAINT `iseq_flowcell_study_fk` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) -) ENGINE=InnoDB AUTO_INCREMENT=277 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -181,7 +181,7 @@ CREATE TABLE `oseq_flowcell` ( KEY `fk_oseq_flowcell_to_study` (`id_study_tmp`), CONSTRAINT `fk_oseq_flowcell_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_oseq_flowcell_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB AUTO_INCREMENT=147 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -224,7 +224,7 @@ CREATE TABLE `pac_bio_run` ( KEY `fk_pac_bio_run_to_study` (`id_study_tmp`), CONSTRAINT `fk_pac_bio_run_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_pac_bio_run_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB AUTO_INCREMENT=115 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -255,7 +255,7 @@ CREATE TABLE `qc_result` ( KEY `lookup_index` (`id_qc_result_lims`,`id_lims`), KEY `qc_result_id_library_lims_index` (`id_library_lims`), CONSTRAINT `fk_qc_result_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB AUTO_INCREMENT=79 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -305,7 +305,7 @@ CREATE TABLE `sample` ( UNIQUE KEY `sample_uuid_sample_lims_index` (`uuid_sample_lims`), KEY `sample_accession_number_index` (`accession_number`), KEY `sample_name_index` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=990 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -356,7 +356,7 @@ CREATE TABLE `stock_resource` ( KEY `composition_lookup_index` (`id_stock_resource_lims`,`id_sample_tmp`,`id_lims`), CONSTRAINT `fk_stock_resource_to_sample` FOREIGN KEY (`id_sample_tmp`) REFERENCES `sample` (`id_sample_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT, CONSTRAINT `fk_stock_resource_to_study` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE=InnoDB AUTO_INCREMENT=175 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -412,7 +412,7 @@ CREATE TABLE `study` ( UNIQUE KEY `study_uuid_study_lims_index` (`uuid_study_lims`), KEY `study_accession_number_index` (`accession_number`), KEY `study_name_index` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=957 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -433,7 +433,7 @@ CREATE TABLE `study_users` ( PRIMARY KEY (`id_study_users_tmp`), KEY `study_users_study_fk` (`id_study_tmp`), CONSTRAINT `study_users_study_fk` FOREIGN KEY (`id_study_tmp`) REFERENCES `study` (`id_study_tmp`) -) ENGINE=InnoDB AUTO_INCREMENT=265 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -445,7 +445,7 @@ CREATE TABLE `study_users` ( /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-09-09 10:08:31 +-- Dump completed on 2020-09-10 10:12:23 INSERT INTO schema_migrations (version) VALUES ('20141113110635'); INSERT INTO schema_migrations (version) VALUES ('20141113130813');