Changeset 2578


Ignore:
Timestamp:
Aug 15, 2014, 9:34:17 AM (7 years ago)
Author:
Nicklas Nordborg
Message:

References #595: Confirm alignment

Linkf generated files with the 'AlignedSequences?' bioassay. The 'accepted_hits.bam' is linked as a data file, all other files are linked as any-to-any links.

Removed the functionality to transfer the files to BASE.

Location:
extensions/net.sf.basedb.reggie/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/resources/analysis/align_confirm.jsp

    r2499 r2578  
    321321  url += '&path='+encodeURIComponent(folder);
    322322  url += '&itemType=DERIVEDBIOASSAY&itemId='+itemId;
    323   Dialogs.openPopup(url, 'ViewProjectFiles', 900, 600);
     323  Dialogs.openPopup(url, 'ViewProjectFiles', 750, 500);
    324324}
    325325
  • extensions/net.sf.basedb.reggie/trunk/resources/analysis/view_remote_files.js

    r2417 r2578  
    6363    html += '<th>Folder / file</th>';
    6464    html += '<th class="file-size">Size</th>';
    65     html += '<th></th>';
     65    html += '<th>Download</th>';
    6666    html += '</tr>';
    6767    var currentFolder = '-';
     
    8080      {
    8181        html += '<tr class="folder">';
    82         html += '<td>';
    83         html += '<span class="link select-folder" data-folder="'+Strings.encodeTags(folder)+'" title="Select all files">';
    84         html += '<img src="../images/remote_folder.png"></span></td>';
     82        html += '<td><img src="../images/remote_folder.png"></td>';
    8583        html += '<td colspan="3">'+Strings.encodeTags(folder)+'</td>';
    8684        html += '</tr>';
     
    8987     
    9088      html += '<tr class="file highlight">';
    91       html += '<td><input type="checkbox" data-file-no="'+fileNo+'"></td>';
     89      html += '<td></td>';
    9290      html += '<td class="file-name">'+Strings.encodeTags(file.name)+'</td>';
    9391      html += '<td class="file-size">'+Numbers.formatBytes(file.size)+'</td>';
     
    10098    setInnerHTML('files', html);
    10199
    102     var folders = document.getElementsByClassName('select-folder');
    103     for (var folderNo = 0; folderNo < folders.length; folderNo++)
    104     {
    105       Events.addEventHandler(folders[folderNo], 'click', remote.selectFolder);
    106     }
    107    
    108100    var downloadable = document.getElementsByClassName('download-file');
    109101    for (var fileNo = 0; fileNo < downloadable.length; fileNo++)
    110102    {
    111103      Events.addEventHandler(downloadable[fileNo], 'click', remote.downloadFile);
    112     }
    113   }
    114  
    115   remote.selectFolder = function(event)
    116   {
    117     var folder = Data.get(event.currentTarget, 'folder');
    118     var frm = document.forms['reggie'];
    119    
    120     var first = null;
    121     for (var i = 0; i < frm.elements.length; i++)
    122     {
    123       var element = frm.elements[i];
    124       var fileNo = Data.int(element, 'file-no', null);
    125       if (element.type == 'checkbox' && fileNo != null && files[fileNo].folder == folder)
    126       {
    127         if (first == null)
    128         {
    129           first = element;
    130           element.checked = !element.checked;
    131         }
    132         else
    133         {
    134           element.checked = first.checked;
    135         }
    136       }
    137104    }
    138105  }
     
    153120  }
    154121 
    155   remote.saveToBase = function(event)
    156   {
    157     var frm = document.forms['reggie'];
    158    
    159     var numChecked = remote.getSelectedFiles().length;
    160     if (numChecked == 0)
    161     {
    162       Forms.showNotification(frm.elements[0], 'Please select at least one file.', null, 'pointer-below');
    163       return;
    164     }
    165 
    166     var url = 'save_remote_files.jsp?ID='+App.getSessionId();
    167     url += '&clusterId='+encodeURIComponent(Data.get('page-data', 'cluster-id'));
    168     url += '&path='+Data.get('page-data', 'path');
    169     url += '&itemType='+Data.get('page-data', 'item-type');
    170     url += '&itemId='+Data.get('page-data', 'item-id');
    171     Dialogs.openPopup(url, 'SaveToBase', 600, 400);
    172   }
    173  
    174   remote.getSelectedFiles = function()
    175   {
    176     var frm = document.forms['reggie'];
    177     var selected = [];
    178     for (var i = 0; i < frm.elements.length; i++)
    179     {
    180       var element = frm.elements[i];
    181       var fileNo = Data.get(element, 'file-no', null);
    182       if (element.type == 'checkbox' && element.checked && fileNo != null)
    183       {
    184         selected[selected.length] = files[fileNo];
    185       }
    186     }
    187     return selected;
    188   }
    189  
    190122  return remote;
    191123}();
  • extensions/net.sf.basedb.reggie/trunk/resources/analysis/view_remote_files.jsp

    r2417 r2578  
    6666#file-list .folder td
    6767{
    68   padding-top: 1em;
     68  padding-top: 0.5em;
    6969}
    7070
     
    8282#file-list .file td.file-name
    8383{
    84   padding-left: 2em;
     84 
    8585}
    8686
     
    8888
    8989</base:head>
    90 <base:body>
     90<base:body data-read-only="1">
    9191  <h1><%=HTML.encodeTags(path) %></h1>
    9292
     
    107107 
    108108  <base:buttongroup subclass="dialogbuttons" id="dialogbuttons">
    109     <base:button id="btnSaveToBase" title="Save to BASE..." image="saveas.png" />
    110109    <base:button id="close" title="Close" />
    111110  </base:buttongroup>
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/Reggie.java

    r2386 r2578  
    7171 
    7272  /**
     73    Path to the directory on the BASE file system where secondary analysis files
     74    are saved. This directory maps some files to the "project-archive" directory
     75    on the file server.
     76    @since 2.16
     77  */
     78  public static final String SECONDARY_ANALYSIS_DIR = "/home/SCANB/SecondaryAnalysis";
     79
     80  /**
    7381    List all annotation types with the given name.
    7482    @since 2.0
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/DemuxMergeServlet.java

    r2577 r2578  
    123123  public static final String DEMULTIPLEX_METRICS_DIR = "/home/SCANB/DemultiplexMetrics";
    124124 
    125   /**
    126     Path to the directory on the BASE file system where secondary analysis files
    127     are saved. This directory maps some files to the "project-archive" directory
    128     on the file server.
    129   */
    130   public static final String SECONDARY_ANALYSIS_DIR = "/home/SCANB/SecondaryAnalysis";
    131  
    132125  private static final Logger logger =
    133126      LoggerFactory.getLogger(DemuxMergeServlet.class);
     
    12851278              baseFolder = "/debug" + prefixFolder + dataFilesFolder.substring(6)
    12861279              : prefixFolder + dataFilesFolder;
    1287             Directory localDataDir = Directory.getNew(dc, new Path(SECONDARY_ANALYSIS_DIR+baseFolder, Path.Type.DIRECTORY));
     1280            Directory localDataDir = Directory.getNew(dc, new Path(Reggie.SECONDARY_ANALYSIS_DIR+baseFolder, Path.Type.DIRECTORY));
    12881281            for (String fileName : r.files)
    12891282            {
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/MaskAlignServlet.java

    r2568 r2578  
    1818
    1919import net.schmizz.sshj.SSHClient;
     20import net.sf.basedb.core.AnyToAny;
    2021import net.sf.basedb.core.Application;
    2122import net.sf.basedb.core.BioMaterialList;
    2223import net.sf.basedb.core.BooleanParameterType;
     24import net.sf.basedb.core.DataFileType;
    2325import net.sf.basedb.core.DbControl;
    2426import net.sf.basedb.core.DerivedBioAssay;
     27import net.sf.basedb.core.Directory;
    2528import net.sf.basedb.core.Extract;
     29import net.sf.basedb.core.File;
     30import net.sf.basedb.core.FileServer;
     31import net.sf.basedb.core.FileSetMember;
    2632import net.sf.basedb.core.ItemNotFoundException;
    2733import net.sf.basedb.core.ItemQuery;
    2834import net.sf.basedb.core.ItemSubtype;
    2935import net.sf.basedb.core.Job;
     36import net.sf.basedb.core.Path;
    3037import net.sf.basedb.core.Protocol;
    3138import net.sf.basedb.core.SessionControl;
     
    4350import net.sf.basedb.reggie.dao.Annotationtype;
    4451import net.sf.basedb.reggie.dao.BiomaterialList;
     52import net.sf.basedb.reggie.dao.Datafiletype;
    4553import net.sf.basedb.reggie.dao.DemuxedSequences;
     54import net.sf.basedb.reggie.dao.Fileserver;
    4655import net.sf.basedb.reggie.dao.MaskedSequences;
    4756import net.sf.basedb.reggie.dao.Library;
     
    357366          String jobFolder = cluster.getJobFolder() + "/" + jobName;
    358367          String tmpFolder = cluster.getTmpFolder() + "/" + jobName;
     368          String filesOut = jobFolder + "/files.out";
    359369         
    360370          ScriptBuilder script = new ScriptBuilder(jobFolder);
     
    456466         
    457467          script.progress(90, "Copying result files to project archive");
    458           script.cmd("mkdir -p " + projectRoot + tophatFolder);
     468          String archiveFolder = projectRoot + tophatFolder;
     469          script.cmd("mkdir -p " + archiveFolder);
    459470          script.cmd("cp fastq.masked/*.out " + jobFolder);
    460471          script.cmd("cp fastq.masked.tophat/*.out " + jobFolder);
    461           script.cmd("cp fastq.masked/*.out " + projectRoot + tophatFolder);
    462           script.cmd("cp fastq.masked.tophat/* " + projectRoot + tophatFolder);
     472          script.cmd("cp fastq.masked/*.out " + archiveFolder);
     473          script.cmd("cp fastq.masked.tophat/* " + archiveFolder);
     474          script.cmd("ls -1 "+archiveFolder+"/* >> " + filesOut);
    463475          script.newLine();
    464476         
     
    627639      CmdResult masked = cluster.executeCmd(ssh, "cat " + cluster.getJobFolder() + "/" + jobStatus.getJobName() + "/masked.out", 2);
    628640      CmdResult statistics = cluster.executeCmd("cat " + cluster.getJobFolder() + "/" + jobStatus.getJobName() + "/alignment_statistics.out" , 2);
     641      CmdResult files = cluster.executeCmd(ssh, "cat " + cluster.getJobFolder() + "/" + jobStatus.getJobName() + "/files.out", 2);
    629642      if (masked.getExitStatus() == 0 && statistics.getExitStatus() == 0)
    630643      {
    631         long[] reads = parseMaskedAndAlignedOut(sc, job, masked.getStdout(), statistics.getStdout());
     644        long[] reads = parseMaskedAndAlignedOut(sc, job, masked.getStdout(), statistics.getStdout(), files.getStdout());
    632645        // 0 = number of reads after filter, 1 = number of reads after align
    633646        return Values.formatNumber(reads[0]/1000000f, 1) + "M reads after mask; "  + Values.formatNumber(reads[1]/1000000f, 1) + "M reads after alignment";
     
    640653    }
    641654   
    642     private long[] parseMaskedAndAlignedOut(SessionControl sc, Job job, String maskedOut, String alignOut)
     655    private long[] parseMaskedAndAlignedOut(SessionControl sc, Job job, String maskedOut, String alignOut, String filesOut)
    643656    {
    644657      long numReadsAfterMask = -1;
     
    679692        dc = sc.newDbControl();
    680693       
     694        DerivedBioAssay aligned = null;
    681695        if (numReadsAfterMask >= 0)
    682696        {
     
    699713          if (list.size() == 1)
    700714          {
    701             Annotationtype.ALIGNED_PAIRS.setAnnotationValue(dc, list.get(0), numReadsAfterAlign);
    702           }
    703         }
     715            aligned = list.get(0);
     716            Annotationtype.ALIGNED_PAIRS.setAnnotationValue(dc, aligned, numReadsAfterAlign);
     717          }
     718        }
     719       
     720        // Create file links
     721        if (aligned != null)
     722        {
     723          String dataFilesFolder = (String)Annotationtype.DATA_FILES_FOLDER.getAnnotationValue(dc, aligned);
     724          String name = aligned.getName();
     725          String prefixFolder = Rna.isSpecialRna(name) ?
     726              "/" + name.substring(0, name.indexOf('.'))
     727              :  "/" + name.substring(0, 2) + "/" + name.substring(0, 4);
     728          String baseFolder = dataFilesFolder.startsWith("/debug") ?
     729              baseFolder = "/debug" + prefixFolder + dataFilesFolder.substring(6)
     730              : prefixFolder + dataFilesFolder;
     731          Directory localDataDir = Directory.getNew(dc, new Path(Reggie.SECONDARY_ANALYSIS_DIR+baseFolder, Path.Type.DIRECTORY));
     732          FileServer projectArchive = Fileserver.PROJECT_ARCHIVE.load(dc);
     733          DataFileType bamData = Datafiletype.BAM.load(dc);
     734          ItemSubtype bamType = bamData.getGenericType();
     735
     736          int lineNo = 0;
     737          for (String line : filesOut.split("\n"))
     738          {
     739            lineNo++;
     740           
     741            File f = File.getNew(dc, localDataDir);
     742            f.setName(line.substring(line.lastIndexOf("/")+1));
     743            f.setFileServer(projectArchive);
     744            String fileUrl = "sftp://" + projectArchive.getHost() + dataFilesFolder + "/" + f.getName();
     745            try
     746            {
     747              f.setUrl(fileUrl, true);
     748            }
     749            catch (RuntimeException ex)
     750            {
     751              f.setUrl(fileUrl, false);
     752            }
     753            dc.saveItem(f);
     754            if (f.getName().equals("accepted_hits.bam"))
     755            {
     756              f.setDescription(numReadsAfterAlign + " ALIGNED PAIRS");
     757              f.setItemSubtype(bamType);
     758              FileSetMember member = aligned.getFileSet().addMember(f, bamData);
     759            }
     760            else
     761            {
     762              AnyToAny link = AnyToAny.getNewOrExisting(dc, aligned, f.getName(), f, true);
     763              if (!link.isInDatabase()) dc.saveItem(link);
     764            }
     765          }
     766        }
     767       
     768       
    704769        dc.commit();
    705770      }
Note: See TracChangeset for help on using the changeset viewer.