@@ -0,0 +1,3803 @@
+package org.opencb.opencga.app.migrations.v2_2_0.catalog;%0A%0Aimport com.mongodb.client.model.Projections;%0Aimport com.mongodb.client.model.UpdateOneModel;%0Aimport org.bson.Document;%0Aimport org.opencb.opencga.catalog.db.mongodb.MongoDBAdaptorFactory;%0Aimport org.opencb.opencga.catalog.migration.Migration;%0Aimport org.opencb.opencga.catalog.migration.MigrationTool;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport static com.mongodb.client.model.Filters.eq;%0A%0A@Migration(id = %22fix_non_existing_mois_from_panels%22,%0A        description = %22Remove non-existing MOIs from Panels%22, version = %222.2.0%22,%0A        language = Migration.MigrationLanguage.JAVA,%0A        domain = Migration.MigrationDomain.CATALOG,%0A        date = 20220111)%0Apublic class FixNonExistingMoIFromPanels extends MigrationTool %7B%0A%0A    @Override%0A    protected void run() throws Exception %7B%0A        migrateCollection(MongoDBAdaptorFactory.PANEL_COLLECTION,%0A                new Document(),%0A                Projections.include(%22_id%22, %22genes%22),%0A                (panelDoc, bulk) -%3E %7B%0A                    if (panelDoc != null) %7B%0A                        List%3CDocument%3E newMoi = new ArrayList%3C%3E();%0A                        List%3CDocument%3E genes = new ArrayList%3C%3E(panelDoc.getList(%22genes%22, Document.class));%0A                        for (Document gene : genes) %7B%0A                            String modeOfInheritance = gene.getString(%22modeOfInheritance%22);%0A                            switch (modeOfInheritance) %7B%0A                                case %22AUTOSOMAL_DOMINANT_AND_RECESSIVE%22:%0A                                case %22AUTOSOMAL_DOMINANT_AND_MORE_SEVERE_RECESSIVE%22:%0A                                    // Make this moi dominant%0A                                    gene.put(%22modeOfInheritance%22, %22AUTOSOMAL_DOMINANT%22);%0A%0A                                    // And generate a new one being recessive%0A                                    Document newDoc = new Document(gene);%0A                                    newDoc.put(%22modeOfInheritance%22, %22AUTOSOMAL_RECESSIVE%22);%0A                                    newMoi.add(newDoc);%0A                                    break;%0A                                case %22AUTOSOMAL_DOMINANT_MATERNALLY_IMPRINTED%22:%0A                                case %22AUTOSOMAL_DOMINANT_NOT_IMPRINTED%22:%0A                                case %22AUTOSOMAL_DOMINANT_PATERNALLY_IMPRINTED%22:%0A                                    gene.put(%22modeOfInheritance%22, %22AUTOSOMAL_DOMINANT%22);%0A                                    break;%0A%0A                                // Valid MOI terms%0A                                case %22AUTOSOMAL_DOMINANT%22:%0A                                case %22AUTOSOMAL_RECESSIVE%22:%0A                                case %22X_LINKED_DOMINANT%22:%0A                                case %22X_LINKED_RECESSIVE%22:%0A                                case %22Y_LINKED%22:%0A                                case %22MITOCHONDRIAL%22:%0A                                case %22DE_NOVO%22:%0A                                case %22MENDELIAN_ERROR%22:%0A                                case %22COMPOUND_HETEROZYGOUS%22:%0A                                case %22UNKNOWN%22:%0A                                    break;%0A%0A                                default:%0A                                    logger.warn(%22Unexpected MOI term '%7B%7D' found. Setting it to unknown.%22, modeOfInheritance);%0A                                    gene.put(%22modeOfInheritance%22, %22UNKNOWN%22);%0A                                    break;%0A                            %7D%0A%0A                            genes.addAll(newMoi);%0A%0A                            bulk.add(new UpdateOneModel%3C%3E(%0A                                    eq(%22_id%22, panelDoc.get(%22_id%22)),%0A                                    new Document(%22$set%22, new Document(%22genes%22, genes))));%0A                        %7D%0A                    %7D%0A                %7D%0A        );%0A    %7D%0A%0A%7D%0A

add new migration to remove non-supported mois