Changeset 5766
- Timestamp:
- Dec 2, 2019, 10:52:46 AM (3 years ago)
- Location:
- extensions/net.sf.basedb.reggie/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.reggie/trunk/resources/analysis/vcall_build.js
r5765 r5766 189 189 url += '&cmd=BuildVariantStatistics'; 190 190 191 Wizard.showLoadingAnimation('Performing registration...' );191 Wizard.showLoadingAnimation('Performing registration...', 'variant-statistics-progress'); 192 192 Wizard.asyncJsonRequest(url, vcall.submissionResults, 'POST', JSON.stringify(submitInfo)); 193 193 } -
extensions/net.sf.basedb.reggie/trunk/resources/analysis/vcall_build.jsp
r5763 r5766 121 121 122 122 <div id="wizard-status"></div> 123 <div id="wizard-progress"></div> 123 124 124 125 <table class="navigation" id="navigation"> -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/VariantStatisticsJobCreator.java
r5765 r5766 1 1 package net.sf.basedb.reggie.grid; 2 2 3 import java.io.StringWriter; 3 4 import java.util.Arrays; 5 import java.util.List; 6 import java.util.regex.Matcher; 7 import java.util.regex.Pattern; 4 8 5 9 import org.slf4j.Logger; 6 10 import org.slf4j.LoggerFactory; 7 11 12 import net.sf.basedb.core.BioSource; 8 13 import net.sf.basedb.core.DbControl; 14 import net.sf.basedb.core.DerivedBioAssay; 15 import net.sf.basedb.core.InvalidDataException; 9 16 import net.sf.basedb.core.ItemList; 10 17 import net.sf.basedb.core.ItemNotFoundException; 11 18 import net.sf.basedb.core.ItemParameterType; 19 import net.sf.basedb.core.ItemQuery; 12 20 import net.sf.basedb.core.Job; 21 import net.sf.basedb.core.ProgressReporter; 13 22 import net.sf.basedb.core.SessionControl; 23 import net.sf.basedb.core.Type; 24 import net.sf.basedb.core.query.Expressions; 25 import net.sf.basedb.core.query.Hql; 26 import net.sf.basedb.core.query.Restrictions; 27 import net.sf.basedb.core.snapshot.SnapshotManager; 14 28 import net.sf.basedb.opengrid.JobDefinition; 15 29 import net.sf.basedb.opengrid.OpenGridCluster; … … 17 31 import net.sf.basedb.opengrid.config.ClusterConfig; 18 32 import net.sf.basedb.opengrid.config.JobConfig; 33 import net.sf.basedb.opengrid.filetransfer.StringUploadSource; 19 34 import net.sf.basedb.reggie.Reggie; 20 35 import net.sf.basedb.reggie.XmlConfig; 36 import net.sf.basedb.reggie.dao.Annotationtype; 37 import net.sf.basedb.reggie.dao.Subtype; 21 38 import net.sf.basedb.util.Values; 39 import net.sf.basedb.util.export.TableWriter; 22 40 23 41 /** … … 61 79 @return The corresponding job in BASE 62 80 */ 63 public Job createVariantStatisticsJob(DbControl dc, OpenGridCluster cluster, ItemList list) 81 @SuppressWarnings("unchecked") 82 public Job createVariantStatisticsJob(DbControl dc, OpenGridCluster cluster, ItemList list, ProgressReporter progress) 64 83 { 65 84 SessionControl sc = dc.getSessionControl(); … … 94 113 // TODO -- Create script here 95 114 96 // TODO -- we need to export a file with paths to raw VCF:s and patient information97 98 99 115 script.progress(99, "Cleaning up temporary folders"); 100 116 117 // Export a list with PATIENT name and path to RAW VCF file 118 StringWriter vcfList = new StringWriter(list.getSize()*80); 119 TableWriter tw = new TableWriter(vcfList); 120 // For each alignment we need to find the patient. We design a query 121 // to load it from the specimen name which we get by cutting the front 122 // of the alignment name 123 ItemQuery<BioSource> findPatBySpecimen = BioSource.getQuery(); 124 Subtype.PATIENT.addFilter(dc, findPatBySpecimen); 125 findPatBySpecimen.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 126 findPatBySpecimen.join(Hql.innerJoin("childCreationEvents", "cce")); 127 findPatBySpecimen.join(Hql.innerJoin("cce", "event", "evt")); 128 findPatBySpecimen.join(Hql.innerJoin("evt", "bioMaterial", "cse")); // 'cse' should now reference a case 129 findPatBySpecimen.join(Hql.innerJoin("cse", "childCreationEvents", "cce2")); 130 findPatBySpecimen.join(Hql.innerJoin("cce2", "event", "evt2")); 131 findPatBySpecimen.join(Hql.innerJoin("evt2", "bioMaterial", "spm")); // 'spm' should now reference a specimen/nospecimen 132 findPatBySpecimen.restrict(Restrictions.eq(Hql.property("spm", "name"), Expressions.parameter("specimen"))); 133 134 ItemQuery<DerivedBioAssay> query = (ItemQuery<DerivedBioAssay>)list.getMembers(); 135 query.setIncludes(Reggie.INCLUDE_IN_CURRENT_PROJECT); 136 List<DerivedBioAssay> alignments = query.list(dc); 137 138 SnapshotManager manager = new SnapshotManager(); 139 int count = 0; 140 int total = alignments.size(); 141 Pattern specimenName = Pattern.compile("(\\d+\\.\\d+)\\..*"); // Extract specimen name by taking first part of alignment name 142 for (DerivedBioAssay alignment : alignments) 143 { 144 count++; 145 if (progress != null && count % 100 == 0) 146 { 147 progress.display(count * 90 / total, "Exporting Patient and VCF list (" + count + " of " + total + ")..."); 148 } 149 150 Matcher m = specimenName.matcher(alignment.getName()); 151 if (!m.matches()) 152 { 153 throw new InvalidDataException("Could not get specimen name for alignment: "+ alignment.getName()); 154 } 155 156 String specimen = m.group(1); 157 findPatBySpecimen.setParameter("specimen", specimen, Type.STRING); 158 List<BioSource> patients = findPatBySpecimen.list(dc); 159 if (patients.size() != 1) 160 { 161 if (patients.size() == 0) throw new ItemNotFoundException("Could not find a patient item for alignment: " +alignment.getName()); 162 throw new InvalidDataException("Found "+ patients.size() + " patient items for alignment: " + alignment.getName()); 163 } 164 String patient = patients.get(0).getName(); 165 String dataFolder = (String)Annotationtype.DATA_FILES_FOLDER.getAnnotationValue(dc, manager, alignment); 166 tw.tablePrintData(patient, dataFolder+"/variants-raw.vcf.gz"); 167 } 168 tw.flush(); 169 tw.close(); 170 101 171 JobDefinition jobDef = new JobDefinition("VariantStatistics", jobConfig, statJob); 102 172 jobDef.setDebug(debug); 173 jobDef.addFile(new StringUploadSource("vcflist.txt", vcfList.toString())); 103 174 jobDef.setCmd(script.toString()); 104 175 -
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/VariantCallingServlet.java
r5765 r5766 29 29 import net.sf.basedb.core.RawBioAssay; 30 30 import net.sf.basedb.core.SessionControl; 31 import net.sf.basedb.core.SimpleProgressReporter; 31 32 import net.sf.basedb.core.Software; 32 33 import net.sf.basedb.core.Trashcan; … … 530 531 } 531 532 533 SimpleProgressReporter progress = new SimpleProgressReporter(null); 534 sc.setSessionSetting("variant-statistics-progress", progress); 535 532 536 ItemList list = ItemList.getById(dc, listId.intValue()); 533 537 … … 536 540 jobCreator.setPriority(priority == null ? null : priority.intValue()); 537 541 538 Job statJob = jobCreator.createVariantStatisticsJob(dc, cluster, list );542 Job statJob = jobCreator.createVariantStatisticsJob(dc, cluster, list, progress); 539 543 if (statJob.getStatus() == Job.Status.ERROR) 540 544 { … … 545 549 jsonMessages.add("Submitted variant statistics job to " + cluster.getConnectionInfo().getName() + " with id " + statJob.getExternalId()); 546 550 } 551 progress.display(100, "Done"); 547 552 dc.commit(); 548 549 553 } 550 554 … … 564 568 if (dc != null) dc.close(); 565 569 json.writeJSONString(resp.getWriter()); 570 sc.setSessionSetting("variant-statistics-progress", null); 566 571 } 567 572
Note: See TracChangeset
for help on using the changeset viewer.