Changeset 4540


Ignore:
Timestamp:
Jan 8, 2014, 10:48:49 AM (10 years ago)
Author:
Fredrik Levander
Message:

Refs #819, Refs #821. Clearing cluster IDs before matching. Fix when multiple hits with same FDR but different e-values.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/client/servlet/src/org/proteios/action/ActionFactory.java

    r4421 r4540  
    4848import org.proteios.action.hit.ViewHit;
    4949import org.proteios.action.hit.ViewHitExternalId;
     50import org.proteios.action.hit.ViewHitFeature;
    5051import org.proteios.action.hit.ViewHitPDBFile;
    5152import org.proteios.action.hit.ViewHitSearchResultFile;
     
    683684                link = getActionLink(ViewHitSubHits.class, label);
    684685            }
     686            else if (key.equals("PrecursorQuantity"))
     687            {
     688                link = getActionLink(ViewHitFeature.class, label);
     689            }
    685690            else if (key.equals("Protein"))
    686691            {
  • trunk/plugin/src/org/proteios/plugins/ClearFeatures.java

    r4310 r4540  
    7676  {
    7777    return new AboutImpl("Clear Features", "Clear features in project",
    78       "0.1", "2012, Fredrik Levander", null, null,
     78      "0.2", "2012-2014, Fredrik Levander", null, null,
    7979      "http://www.proteios.org");
    8080  }
     
    118118        int updatedFeatures = removeFeatureSequences(project, dc);
    119119        dc.commit();
     120        int deletedIds = clearClusterIds(project,sc);
    120121        response
    121           .setDone(updatedFeatures + " feature sequences removed. " + updatedHits + " hits updated. " + removedAligned + " aligned hits deleted.");
     122          .setDone(updatedFeatures + " feature sequences removed. " + updatedHits + " hits updated. " + removedAligned + " aligned hits deleted. " + deletedIds + " cluster IDs removed.");
    122123      }
    123124      else
     
    146147    QueryFactory qf = new QueryFactory();
    147148    ItemQuery<Hit> hitQuery = qf.select(Hit.class);
    148     hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"), Hql
    149       .entity(project)));
     149    hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"),
     150      Hql.entity(project)));
    150151    hitQuery.restrictPermanent(Restrictions.eq(Hql.property("scoreType"),
    151152      Expressions.string("Proteios aligned")));
     
    176177    QueryFactory qf = new QueryFactory();
    177178    ItemQuery<Hit> hitQuery = qf.select(Hit.class);
    178     hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"), Hql
    179       .entity(project)));
    180     hitQuery.restrictPermanent(Restrictions.neq(Hql
    181       .property("precursorQuantity"), null));
     179    hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"),
     180      Hql.entity(project)));
     181    hitQuery.restrictPermanent(Restrictions.neq(
     182      Hql.property("precursorQuantity"), null));
    182183    for (Iterator<Hit> iter = hitQuery.iterate(dc); iter.hasNext();)
    183184    {
     
    189190    }
    190191    hitQuery = qf.select(Hit.class);
    191     hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"), Hql
    192       .entity(project)));
    193     hitQuery.restrictPermanent(Restrictions.eq(Hql
    194       .property("precursorQuantity"), null));
     192    hitQuery.restrictPermanent(Restrictions.eq(Hql.property("project"),
     193      Hql.entity(project)));
     194    hitQuery.restrictPermanent(Restrictions.eq(
     195      Hql.property("precursorQuantity"), null));
    195196    hitQuery.restrictPermanent(Restrictions.neq(Hql.property("feature"),
    196197      null));
     
    216217    QueryFactory qf = new QueryFactory();
    217218    ItemQuery<Feature> query = qf.select(Feature.class);
    218     query.restrictPermanent(Restrictions.eq(Hql.property("project"), Hql
    219       .entity(project)));
     219    query.restrictPermanent(Restrictions.eq(Hql.property("project"),
     220      Hql.entity(project)));
    220221    query.restrict(Restrictions.neq(Hql.property("peptideSequence"), null));
    221222    for (Iterator<Feature> iter = query.iterate(dc); iter.hasNext();)
     
    247248    for (File msFile : files)
    248249    {
    249       log
    250         .debug("Deleting features for file " + (++count) + " of " + nFiles);
     250      log.debug("Deleting features for file " + (++count) + " of " + nFiles);
    251251      nDeleted += Feature.deleteAllFeatures(project, msFile, sessc);
    252252    }
     
    254254    return nDeleted;
    255255  }
     256
     257
     258  /**
     259   * Delete all cluster Ids for features in project. This is performed for one msFile at
     260   * the time to avoid stalling. The deletions are committed to the database
     261   * after each batch delete.
     262   *
     263   * @return the number of deleted rows
     264   */
     265  public static int clearClusterIds(Project project, SessionControl sessc)
     266  {
     267    int nDeleted = 0;
     268    DbControl dc = sessc.newDbControl();
     269    List<File> files = Feature.getUniqueMsFiles(project, dc);
     270    int nFiles = files.size();
     271    int count = 0;
     272    for (File msFile : files)
     273    {
     274      log.debug("Deleting features for file " + (++count) + " of " + nFiles);
     275      nDeleted += clearClusterIds(project, msFile, sessc);
     276    }
     277    dc.close();
     278    return nDeleted;
     279  }
     280
     281
     282  /**
     283   * Delete all cluster Ids for features from a msFile in a project
     284   *
     285   * @param project
     286   * @param msFile File
     287   * @param sessc Session Control
     288   * @return number of updated rows
     289   */
     290  public static int clearClusterIds(Project project, File msFile,
     291      SessionControl sessc)
     292  {
     293    int nUpdated = 0;
     294    DbControl dc = sessc.newDbControl();
     295    QueryFactory qf = new QueryFactory();
     296    ItemQuery<Feature> featureQuery = qf.select(Feature.class);
     297
     298    // Only features in project should be retrieved
     299    // OBS! has hql object as input
     300    featureQuery.restrictPermanent(Restrictions.eq(Hql.property("project"),
     301      Hql.entity(project)));
     302    featureQuery.restrict(Restrictions.eq(Hql.property("msFile"),
     303      Hql.entity(msFile)));
     304    featureQuery
     305      .restrict(Restrictions.neq(Hql.property("clusterId"), null));
     306
     307    for (Iterator<Feature> iter = featureQuery.iterate(dc); iter.hasNext();)
     308    {
     309      Feature feature = iter.next();
     310      dc.reattachItem(feature);
     311      feature.setClusterId(null);
     312      nUpdated++;
     313    }
     314    dc.commit();
     315    return nUpdated;
     316  }
    256317}
  • trunk/plugin/src/org/proteios/plugins/FeatureHitMatcher.java

    r4535 r4540  
    9999    return new AboutImpl("Match features to hits",
    100100        "Match features to hits for a project", "0.5",
    101         "2009-2013, Marianne Sandin, Fredrik Levander", null, null,
     101        "2009-2014, Marianne Sandin, Fredrik Levander", null, null,
    102102        "http://www.proteios.org");
    103103  }
     
    123123      // Start by removing previous matches
    124124      if (progress != null) {
    125         progress.display(5, "Removing previous matches");
     125        progress.display(2, "Removing previous matches");
    126126      }
    127127      Project project = (Project) job.getValue("project");
     
    129129      dc.commit();
    130130      if (progress != null) {
    131         progress.display(5, "Removed aligned hits");
     131        progress.display(4, "Removed aligned hits");
    132132      }
    133133      dc = sc.newDbControl();
     
    136136      dc.commit();
    137137      if (progress != null) {
    138         progress.display(5, "Removed feature and hits connections");
     138        progress.display(6, "Removed feature and hits connections");
    139139      }
    140140      dc = sc.newDbControl();
     
    143143      dc.commit();
    144144      if (progress != null) {
    145         progress.display(5, "Removed feature sequences");
    146       }
     145        progress.display(8, "Removed feature sequences");
     146      }
     147      ClearFeatures.clearClusterIds(project, sc);
     148      if (progress != null) {
     149        progress.display(10, "Removed feature cluster Ids");
     150      }     
    147151      // Done with init
    148152      dc = sc.newDbControl();
     
    486490                        .getCombinedFDR())
    487491                      best = false;
    488                     if (hh.getCombinedFDR() == h.getCombinedFDR())
     492                    if (hh.getCombinedFDR().equals(h.getCombinedFDR()))
    489493                      if (hh.getExpectationValue()<=h.getExpectationValue())
    490494                        best = false;
     
    713717    hitQuery.order(Orders.asc(Hql.property("charge")));
    714718    hitQuery.order(Orders.asc(Hql.property("experimentalMassInDaltons")));
     719    hitQuery.order(Orders.asc(Hql.property("combinedFDR")));
     720    hitQuery.order(Orders.asc(Hql.property("expectationValue")));
    715721    ItemResultList<Hit> hitlist = hitQuery.list(dc);
    716722    for (Hit h : hitlist) {
  • trunk/plugin/src/org/proteios/plugins/FeatureSequencePropagator.java

    r4524 r4540  
    268268
    269269          dc.commit();
    270           dc = sc.newDbControl();
    271 
    272           featureQuery.restrict(Restrictions.eq(
    273               Hql.property("msFile"), Hql.entity(currentMsFile)));
    274           featureQuery.restrict(Restrictions.neq(
    275               Hql.property("clusterId"), null));
    276 
    277           List<Feature> allClusterIdFeatures = featureQuery.list(dc);
    278 
     270         
    279271          if (progress != null) {
    280272            progress.display((fileNbr + 1) / nbrOfFiles,
     
    282274                    + (fileNbr + 1));
    283275          }
    284 
    285           for (Feature clusterF : allClusterIdFeatures) {
    286 
    287             clusterF.setClusterId(null);
    288             dc.reattachItem(clusterF);
    289 
    290           }
    291 
    292           dc.commit();
     276         
     277          ClearFeatures.clearClusterIds(project, currentMsFile, sc);
     278         
    293279          dc = sc.newDbControl();
    294280
Note: See TracChangeset for help on using the changeset viewer.