Changeset 1532


Ignore:
Timestamp:
Feb 9, 2007, 3:22:39 PM (14 years ago)
Author:
fredrik
Message:

Combined report changed to allow for comparison on peptide level as well as on protein level. It is still specific for Tandem and Mascot. For peptide reports the MW will contain the spectrumId of the spectrum that returned the result. Tandem results that were reported prior to the latest import bug fix will have the same accession number repeated multiple times if the sequence was contained in more than one protein. It will be correct for newly imported Tandem results.

Location:
trunk/src/org/proteios
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/proteios/gui/query/CombinedProteinHitsReportEditor.java

    r1530 r1532  
    5757    CombinedProteinHitsReportQuery pQuery = (CombinedProteinHitsReportQuery)query;
    5858    pQuery.setReverseText(reverseText.getText());
     59    if (peptidesButton.isSelected())
     60    {
     61      pQuery.setIsProteinScores(false);
     62    }
     63    else
     64    {
     65      pQuery.setIsProteinScores(true);
     66    }
    5967    if (dateCheckBox.isSelected())
    6068    {
     
    8492  {
    8593    setBackground(new java.awt.Color(102, 204, 255));
    86     setBorder(new javax.swing.border.TitledBorder("Settings for combined gel report"));
     94    setBorder(new javax.swing.border.TitledBorder("Mascot and Tandem combined report"));
    8795    setMinimumSize(new java.awt.Dimension(72, 90));
    8896    setPreferredSize(new java.awt.Dimension(116, 90));
     
    135143    JPanel main = new JPanel();
    136144    main.setBorder(BorderFactory.createLineBorder(Color.darkGray));
    137     main.setLayout(new java.awt.GridLayout(5, 1));
     145    main.setLayout(new java.awt.GridLayout(6, 1));
    138146    main.setBackground(new java.awt.Color(255, 255, 255));
    139147    add(main);
     
    153161    /* End of text label */
    154162   
     163    /**  The sorting panel */
     164    JPanel sortingPanel = new JPanel();
     165    sortingPanel.setBackground(new java.awt.Color(255, 255, 255));
     166   
     167    JLabel sortingLabel = new JLabel("Calculate for protein or peptides:  ");
     168    sortingLabel.setBackground(new java.awt.Color(255, 255, 255));
     169    sortingPanel.add(sortingLabel);
     170   
     171    proteinsButton = new JRadioButton("proteins", true);
     172    proteinsButton.setActionCommand("proteins");
     173    proteinsButton.addActionListener(listener);
     174    proteinsButton.setBackground(new java.awt.Color(255, 255, 255));
     175    sortingPanel.add(proteinsButton);
     176   
     177    peptidesButton = new JRadioButton("peptides");
     178    peptidesButton.setActionCommand("peptides");
     179    peptidesButton.addActionListener(listener);
     180    peptidesButton.setBackground(new java.awt.Color(255, 255, 255));
     181    sortingPanel.add(peptidesButton);
     182     
     183    ButtonGroup bg = new ButtonGroup();
     184    bg.add(proteinsButton);
     185    bg.add(peptidesButton);
     186   
     187    main.add(sortingPanel);
     188    /** End of the sorting panel */
     189
    155190    /**  The fdr cut off panel */
    156191    JPanel cutOffPanel = new JPanel();
     
    232267  /** Gui components */
    233268  private JCheckBox dateCheckBox, cutOffCheckBox, dateCheckBox2;
     269  private JRadioButton proteinsButton, peptidesButton;
    234270  private JSpinner cutOffSpinner;
    235271  private JTextField dateText, dateText2, reverseText;
  • trunk/src/org/proteios/query/CombinedProteinHitsReportQuery.java

    r1526 r1532  
    1515// along with this program; if not, write to the Free Software
    1616// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
    17 
    1817package org.proteios.query;
    1918
    2019import java.text.SimpleDateFormat;
    21 import java.text.DateFormat;
     20import java.util.ArrayList;
    2221import java.util.Date;
     22import java.util.HashMap;
     23import java.util.Iterator;
    2324import java.util.List;
    24 import java.util.ArrayList;
    25 import java.util.TreeSet;
     25import java.util.Map;
    2626import java.util.Set;
    2727import java.util.SortedSet;
    28 import java.util.Iterator;
    29 import java.util.Map;
    30 import java.util.HashMap;
    31 
     28import java.util.TreeSet;
     29import org.proteios.core.SQLConnection;
    3230import org.proteios.core.SQLEvictConnection;
    33 import org.proteios.core.SQLConnection;
    34 
    35 import org.proteios.core.Element;
    3631import org.proteios.core.element.Gel;
    3732import org.proteios.core.element.Gel1D;
    38 import org.proteios.core.element.Gel2D;
     33import org.proteios.core.element.IdentificationHypothesis;
     34import org.proteios.core.element.MoleculeIdentifier;
     35import org.proteios.core.element.MzAnalysis;
     36import org.proteios.core.element.MzData;
     37import org.proteios.core.element.ParentMolecule;
     38import org.proteios.core.element.PolyPeptide;
     39import org.proteios.core.element.Result;
    3940import org.proteios.core.element.Spot;
    40 import org.proteios.core.element.Band;
    41 import org.proteios.core.element.MzData;
    42 import org.proteios.core.element.SpectrumList;
    43 import org.proteios.core.element.Spectrum;
    44 import org.proteios.core.element.PeakList;
    45 import org.proteios.core.element.Peak;
    46 import org.proteios.core.element.HypothesisProperty;
    47 import org.proteios.core.element.MzAnalysis;
    48 import org.proteios.core.element.Result;
    49 import org.proteios.core.element.IdentificationHypothesis;
    50 import org.proteios.core.element.PolyPeptide;
    51 import org.proteios.core.element.ParentMolecule;
    52 import org.proteios.core.element.MoleculeIdentifier;
    5341import org.proteios.core.element.UserModification;
    5442
    5543/**
    56   This class generate a protein list with user-defined error ratio
    57 
    58   @author Fredrik Levander
    59 
    60 */
     44 * This class generate a protein list with user-defined error ratio
     45 *
     46 * @author Fredrik Levander
     47 */
    6148public class CombinedProteinHitsReportQuery
    62   extends Query
     49    extends Query
    6350{
    6451  public CombinedProteinHitsReportQuery()
     
    6956
    7057  /**
    71   * Executable if the object we query from is either Gel1D or Gel2D (i.e.
    72   * instanceof Gel) and all parameters set.
    73   *
    74   * @return true if query is executable.
    75   */
     58   * Executable if the object we query from is either Gel1D or Gel2D (i.e.
     59   * instanceof Gel) and all parameters set.
     60   *
     61   * @return true if query is executable.
     62   */
    7663  public boolean isExecutable()
    7764  {
     
    8168
    8269  /**
    83   * Set query origin and set executable if Gel.
    84   *
    85   * @param origin The gel that is being queried.
    86   * @param parent The query object's parent - null is OK.
    87   */
     70   * Set query origin and set executable if Gel.
     71   *
     72   * @param origin The gel that is being queried.
     73   * @param parent The query object's parent - null is OK.
     74   */
    8875  public void setQueryOrigin(Object queryObject, Object parentObject)
    8976  {
     
    9582  /** Once all parameters needed to run the query have been supplied. */
    9683  public QueryResult execute()
    97     throws QueryException
     84      throws QueryException
    9885  {
    9986    if (executable == false)
    10087    {
    101       throw new QueryException("Unable to execute " + query_name + " from: " + queryObject);
     88      throw new QueryException(
     89        "Unable to execute " + query_name + " from: " + queryObject);
    10290    }
    10391    resultSet = getResult();
    104     CombinedProteinHitsReportQueryResult result = new CombinedProteinHitsReportQueryResult(resultSet);
     92    CombinedProteinHitsReportQueryResult result = new CombinedProteinHitsReportQueryResult(
     93      resultSet);
    10594    result.setGelId(gelId);
    10695    result.setInfo(info);
    10796    return result;
    10897  }
    109  
    110  
    111   /**
    112     Will exctract info from the proteios data structure and create
    113     a TreeSet containing sorted ResultRow objects.
    114   */
    115   private Set getResult()
    116     throws QueryException
     98
     99
     100  public Set getProteinSet(Gel gel)
     101      throws QueryException
    117102  {
    118103    Set result = new TreeSet();
    119     Gel gel = (Gel)queryObject;
    120     gelId = gel.getGel_id();
    121     int total_results=0;
    122     int score_types=1;
    123     int db_entries=0;
    124104    try
    125105    {
    126       // Iterate through all the spots and find assosciated mzData elements
    127       Map attributes=new HashMap();
    128       dbconnection=new SQLEvictConnection((SQLConnection) gel.getDataConnection());
     106      dbconnection = new SQLEvictConnection((SQLConnection) gel
     107        .getDataConnection());
    129108      dbconnection.beginTransaction();
    130109      List proteinList = null;
    131110      List parentMoleculeList = null;
    132 
     111      String gelSpotType = "spot.gel2D";
    133112      // Gel is either Gel1D or Gel2D with Band or Spot respectively.
    134       // We check if there are results from one or two search engines
    135113      if (gel instanceof Gel1D)
    136114      {
    137         String query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.score_type='Mascot protein score'";
    138         query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel1D.gel_id='"+gelId+"'";
    139         proteinList= dbconnection.getQueryResult(query_string);
    140         if (proteinList!=null && !proteinList.isEmpty())
    141         query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.result.mzAnalysis.softwareName='X!Tandem'";
    142         query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel1D.gel_id='"+gelId+"'";
    143         proteinList.addAll(dbconnection.getQueryResult(query_string));
    144         query_string="from ParentMolecule pm where pm.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel1D.gel_id='"+gelId+"'";
    145         parentMoleculeList=dbconnection.getQueryResult(query_string);
    146       }
    147       else if (gel instanceof Gel2D)
    148       {
    149         String query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.score_type='Mascot protein score'";
    150         query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel2D.gel_id='"+gelId+"'";
    151         proteinList= dbconnection.getQueryResult(query_string);
    152         query_string="from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.result.mzAnalysis.softwareName='X!Tandem'";
    153         query_string+=" and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel2D.gel_id='"+gelId+"'";
    154         proteinList.addAll(dbconnection.getQueryResult(query_string));
    155         query_string="from ParentMolecule pm where pm.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData.spot.gel2D.gel_id='"+gelId+"'";
    156         parentMoleculeList=dbconnection.getQueryResult(query_string);
    157       }
    158 
     115        gelSpotType = "band.gel1D";
     116      }
     117      String query_string = "from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.score_type='Mascot protein score'";
     118      query_string += " and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'";
     119      proteinList = dbconnection.getQueryResult(query_string);
     120      query_string = "from MoleculeIdentifier mi where mi.polyPeptide.identificationHypothesis.result.mzAnalysis.softwareName='X!Tandem'";
     121      query_string += " and mi.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'";
     122      proteinList.addAll(dbconnection.getQueryResult(query_string));
     123      query_string = "from ParentMolecule pm where pm.polyPeptide.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'";
     124      parentMoleculeList = dbconnection.getQueryResult(query_string);
    159125      if (proteinList == null || proteinList.isEmpty())
    160126      {
    161         throw new QueryException("There are no identifications that fulfil the criteria for this gel.");
    162       }
    163       System.out.println("Proteins:"+proteinList.size()+" ParentMolecules:"+parentMoleculeList.size());
    164       total_results=proteinList.size();
     127        throw new QueryException(
     128          "There are no identifications that fulfil the criteria for this gel.");
     129      }
     130      System.out
     131        .println("Proteins:" + proteinList.size() + " ParentMolecules:" + parentMoleculeList
     132          .size());
    165133      Iterator protIter = proteinList.iterator();
    166134      // First populate the protein list with identification info
    167135      while (protIter.hasNext())
    168136      {
    169         MoleculeIdentifier currentMI = (MoleculeIdentifier)protIter.next();
     137        MoleculeIdentifier currentMI = (MoleculeIdentifier) protIter
     138          .next();
    170139        ResultRow row = new ResultRow();
    171140        PolyPeptide currentPP = currentMI.getPolyPeptide();
    172         IdentificationHypothesis currentHypothesis = currentPP.getIdentificationHypothesis();
     141        IdentificationHypothesis currentHypothesis = currentPP
     142          .getIdentificationHypothesis();
    173143        row.eValue = currentHypothesis.getE_value();
    174144        row.score = currentHypothesis.getScore();
    175145        row.score_type = currentHypothesis.getScore_type();
    176         // The score type was not written in some old Tandem imports. 
     146        // The score type was not written in some old Tandem imports.
    177147        // It is supposed to be there for all other imports
    178148        if (row.score_type.equals(""))
    179149        {
    180           row.score_type="Tandem";
     150          row.score_type = "Tandem";
    181151        }
    182152        row.proteinId = currentMI.getAccession_number();
    183         // Sometimes IPI accessions are preceeded by IPI: which should be removed
     153        // Sometimes IPI accessions are preceeded by IPI: which should
     154        // be removed
    184155        if (row.proteinId.startsWith("IPI:"))
    185156        {
    186           row.proteinId=row.proteinId.substring(4);
     157          row.proteinId = row.proteinId.substring(4);
    187158          if (row.proteinId.contains("|"))
    188159          {
    189             row.proteinId=row.proteinId.substring(0,row.proteinId.indexOf('|'));
    190           }
    191         }
    192         Result currentResult=currentHypothesis.getResult();
    193         MzAnalysis currentAnalysis=currentResult.getMzAnalysis();
    194         if (db_entries==0)
    195         {
    196           if (currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy()!=0)
    197           {
    198             db_entries=currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy();
    199           }
     160            row.proteinId = row.proteinId.substring(0,
     161              row.proteinId.indexOf('|'));
     162          }
     163        }
     164        Result currentResult = currentHypothesis.getResult();
     165        MzAnalysis currentAnalysis = currentResult.getMzAnalysis();
     166        if (db_entries == 0)
     167        {
     168          if (currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy() != 0)
     169          {
     170            db_entries = currentAnalysis
     171              .getSearchDatabaseEntriesAfterTaxonomy();
     172          }
    200173          else
    201174          {
    202             db_entries=currentAnalysis.getSearchDatabaseSizeInDbEntries(); 
    203           }
    204         }
    205         MzData currentMzData=currentAnalysis.getMzData();
    206         Spot currentSpot=currentMzData.getSpot();
    207         row.spotId=(int) currentSpot.getId();
    208         row.dBSearchId=dfXML.parse(currentAnalysis.getAnalysisTime());
    209         row.description=currentMI.getName();
    210         row.mw=currentMI.getPredicted_mass();
    211         row.pi=currentMI.getPredicted_pI();
    212         boolean add=true;
     175            db_entries = currentAnalysis
     176              .getSearchDatabaseSizeInDbEntries();
     177          }
     178        }
     179        MzData currentMzData = currentAnalysis.getMzData();
     180        Spot currentSpot = currentMzData.getSpot();
     181        row.spotId = (int) currentSpot.getId();
     182        row.dBSearchId = dfXML.parse(currentAnalysis.getAnalysisTime());
     183        row.description = currentMI.getName();
     184        row.mw = currentMI.getPredicted_mass();
     185        row.pi = currentMI.getPredicted_pI();
     186        boolean add = true;
    213187        if (getDate() != null)
    214188        {
    215           if (!dfXML.format(row.dBSearchId).startsWith(getDate()) && row.score_type.startsWith("Mascot"))
    216           {
    217             add=false;
     189          if (!dfXML.format(row.dBSearchId).startsWith(getDate()) && row.score_type
     190            .startsWith("Mascot"))
     191          {
     192            add = false;
    218193          }
    219194        }
    220195        if (getDate2() != null)
    221196        {
    222           if (!dfXML.format(row.dBSearchId).startsWith(getDate2()) && row.score_type.startsWith("Tandem"))
    223           {
    224             add=false;
    225           }
    226         }
    227         if (row.score_type.startsWith("Mascot") && (row.score==0.0))
    228         {
    229           add=false;
     197          if (!dfXML.format(row.dBSearchId).startsWith(getDate2()) && row.score_type
     198            .startsWith("Tandem"))
     199          {
     200            add = false;
     201          }
     202        }
     203        if (row.score_type.startsWith("Mascot") && (row.score == 0.0))
     204        {
     205          add = false;
    230206        }
    231207        if (add)
    232208        {
    233209          // Find subsequence hits:
    234          
    235           /*String pepID=Long.toString(currentPP.getId());
    236           /String new_query="from ParentMolecule pm where pm.polyPeptideId='"+pepID+"'";
    237           List pmlist=dbconnection.getQueryResult(new_query);*/
    238           long pepID=currentPP.getId();
    239           Iterator parentIt=parentMoleculeList.iterator();
    240           List pmlist=new ArrayList();
     210          long pepID = currentPP.getId();
     211          Iterator parentIt = parentMoleculeList.iterator();
    241212          ParentMolecule currentpm;
    242213          while (parentIt.hasNext())
    243214          {
    244             currentpm=(ParentMolecule) parentIt.next();
    245             //long currentID=currentpm.getPolyPeptideId();
    246             if (pepID==currentpm.getPolyPeptideId())
    247             {
    248               PolyPeptide currentpp=currentpm.getPolyPeptide();
    249               IdentificationHypothesis currentih=currentpp.getIdentificationHypothesis();
    250               row.identificationHypotheses.add(currentih.getAuto_id());
    251             }
    252           }
    253         // end of subsequence find part
     215            currentpm = (ParentMolecule) parentIt.next();
     216            // long currentID=currentpm.getPolyPeptideId();
     217            if (pepID == currentpm.getPolyPeptideId())
     218            {
     219              PolyPeptide currentpp = currentpm.getPolyPeptide();
     220              IdentificationHypothesis currentih = currentpp
     221                .getIdentificationHypothesis();
     222              row.identificationHypotheses.add(currentih
     223                .getAuto_id());
     224            }
     225          }
     226          // end of subsequence find part
    254227          result.add(row);
    255228        }
     
    262235      throw new QueryException("Error building report: " + e.getMessage());
    263236    }
    264    
    265237    // Now mark subsequence hits and remove them!
    266     Iterator resit=result.iterator();
     238    Iterator resit = result.iterator();
    267239    while (resit.hasNext())
    268240    {
    269       ResultRow row=(ResultRow) resit.next();
    270       boolean subsequence=false;
    271       Iterator res2it=result.iterator();
     241      ResultRow row = (ResultRow) resit.next();
     242      boolean subsequence = false;
     243      Iterator res2it = result.iterator();
    272244      while (res2it.hasNext() && !subsequence)
    273245      {
    274         ResultRow row2=(ResultRow) res2it.next();
    275         if (row.spotId==row2.spotId && row.score_type==row2.score_type)
    276         {
    277           if (row.identificationHypotheses.size()<row2.identificationHypotheses.size())
    278           {
    279             boolean allmatched=true;
    280             Iterator ihit=row.identificationHypotheses.iterator();
     246        ResultRow row2 = (ResultRow) res2it.next();
     247        if (row.spotId == row2.spotId && row.score_type == row2.score_type)
     248        {
     249          if (row.identificationHypotheses.size() < row2.identificationHypotheses
     250            .size())
     251          {
     252            boolean allmatched = true;
     253            Iterator ihit = row.identificationHypotheses.iterator();
    281254            while (ihit.hasNext())
    282255            {
    283               Long ihid=(Long) ihit.next();
    284               boolean matched=false;
    285               Iterator ih2it=row2.identificationHypotheses.iterator();
     256              Long ihid = (Long) ihit.next();
     257              boolean matched = false;
     258              Iterator ih2it = row2.identificationHypotheses
     259                .iterator();
    286260              while (ih2it.hasNext() && allmatched)
    287261              {
    288262                if (((Long) ih2it.next()).equals(ihid))
    289263                {
    290                   matched=true;
     264                  matched = true;
    291265                }
    292266              }
    293267              if (!matched)
    294268              {
    295                 allmatched=false;
     269                allmatched = false;
    296270              }
    297271            }
    298272            if (allmatched)
    299273            {
    300               subsequence=true;
     274              subsequence = true;
    301275            }
    302276          }
     
    308282      }
    309283    }
    310 
    311    
    312     resit=result.iterator();
    313     int spots=0;
    314     int lastSpotId=-1;
    315     // Now put the reverse and forward hits into different lists. Count spots
     284    return result;
     285  }
     286
     287
     288  public Set getPeptideSet(Gel gel)
     289      throws QueryException
     290  {
     291    Set result = new TreeSet();
     292    try
     293    {
     294      dbconnection = new SQLEvictConnection((SQLConnection) gel
     295        .getDataConnection());
     296      dbconnection.beginTransaction();
     297      List peptideList = null;
     298      // List parentMoleculeList = null;
     299      String gelSpotType = "spot.gel2D";
     300      // Gel is either Gel1D or Gel2D with Band or Spot respectively.
     301      if (gel instanceof Gel1D)
     302      {
     303        gelSpotType = "band.gel1D";
     304      }
     305      String query_string = "from PolyPeptide pp where pp.identificationHypothesis.score_type='Mascot peptide score'";
     306      query_string += " and pp.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'";
     307      peptideList = dbconnection.getQueryResult(query_string);
     308      query_string = "from PolyPeptide pp where pp.identificationHypothesis.score_type='Tandem hyperscore'";
     309      query_string += " and pp.identificationHypothesis.result.mzAnalysis.mzData." + gelSpotType + ".auto_id='" + gel_autoid + "'";
     310      peptideList.addAll(dbconnection.getQueryResult(query_string));
     311      if (peptideList == null || peptideList.isEmpty())
     312      {
     313        throw new QueryException(
     314          "There are no identifications that fulfil the criteria for this gel.");
     315      }
     316      System.out.println("Peptides:" + peptideList.size());
     317      Iterator pepIter = peptideList.iterator();
     318      // First populate the peptide list with identification info
     319      while (pepIter.hasNext())
     320      {
     321        PolyPeptide currentPP = (PolyPeptide) pepIter.next();
     322        ResultRow row = new ResultRow();
     323        IdentificationHypothesis currentHypothesis = currentPP
     324          .getIdentificationHypothesis();
     325        row.eValue = currentHypothesis.getE_value();
     326        row.score = currentHypothesis.getScore();
     327        row.score_type = currentHypothesis.getScore_type();
     328        row.proteinId = "";
     329        Iterator pmit = currentPP.getParentMoleculeCollection()
     330          .iterator();
     331        while (pmit.hasNext())
     332        {
     333          String desc = ((ParentMolecule) pmit.next())
     334            .getAccession_number();
     335          // Sometimes IPI accessions are preceeded by IPI: which
     336          // should
     337          // be removed
     338          if (desc.startsWith("IPI:"))
     339          {
     340            desc = desc.substring(4);
     341          }
     342          if (desc.contains("|"))
     343          {
     344            desc = desc.substring(0, desc.indexOf('|'));
     345          }
     346          if (row.proteinId.length() > 0)
     347          {
     348            // We want reverse accessions first
     349            if (desc.startsWith(reverseText))
     350            {
     351              row.proteinId = desc + " " + row.proteinId;
     352            }
     353            else
     354            {
     355              row.proteinId = row.proteinId + " " + desc;
     356            }
     357          }
     358          else
     359          {
     360            row.proteinId = desc;
     361          }
     362        }
     363        Result currentResult = currentHypothesis.getResult();
     364        MzAnalysis currentAnalysis = currentResult.getMzAnalysis();
     365        if (db_entries == 0)
     366        {
     367          if (currentAnalysis.getSearchDatabaseEntriesAfterTaxonomy() != 0)
     368          {
     369            db_entries = currentAnalysis
     370              .getSearchDatabaseEntriesAfterTaxonomy();
     371          }
     372          else
     373          {
     374            db_entries = currentAnalysis
     375              .getSearchDatabaseSizeInDbEntries();
     376          }
     377        }
     378        MzData currentMzData = currentAnalysis.getMzData();
     379        Spot currentSpot = currentMzData.getSpot();
     380        row.spotId = (int) currentSpot.getId();
     381        row.dBSearchId = dfXML.parse(currentAnalysis.getAnalysisTime());
     382        row.description = currentPP.getSequence();
     383        Iterator moditerator = currentPP
     384          .getUserModificationCollection().iterator();
     385        while (moditerator.hasNext())
     386        {
     387          row.description += " + " + ((UserModification) moditerator
     388            .next()).getName();
     389        }
     390        row.mw = currentResult.getSpectrumId();
     391        row.pi = 0;
     392        boolean add = true;
     393        if (getDate() != null)
     394        {
     395          if (!dfXML.format(row.dBSearchId).startsWith(getDate()) && row.score_type
     396            .startsWith("Mascot"))
     397          {
     398            add = false;
     399          }
     400        }
     401        if (getDate2() != null)
     402        {
     403          if (!dfXML.format(row.dBSearchId).startsWith(getDate2()) && row.score_type
     404            .startsWith("Tandem"))
     405          {
     406            add = false;
     407          }
     408        }
     409        if (add)
     410        {
     411          result.add(row);
     412        }
     413      }
     414      dbconnection.clear();
     415      dbconnection.closeSession();
     416    }
     417    catch (Exception e)
     418    {
     419      throw new QueryException("Error building report: " + e.getMessage());
     420    }
     421    return result;
     422  }
     423
     424
     425  /**
     426   * Will exctract info from the proteios data structure and create a TreeSet
     427   * containing sorted ResultRow objects.
     428   */
     429  private Set getResult()
     430      throws QueryException
     431  {
     432    Set result = new TreeSet();
     433    Gel gel = (Gel) queryObject;
     434    gelId = gel.getGel_id();
     435    gel_autoid = Long.toString(gel.getAuto_id());
     436    int score_types = 1;
     437    try
     438    {
     439      if (isProteinScores)
     440      {
     441        result = getProteinSet(gel);
     442      }
     443      else
     444      {
     445        result = getPeptideSet(gel);
     446      }
     447    }
     448    catch (QueryException e)
     449    {
     450      throw e;
     451    }
     452    Iterator resit = result.iterator();
     453    int spots = 0;
     454    int lastSpotId = -1;
     455    // Now put the reverse and forward hits into different lists. Count
     456    // spots
    316457    List<FdrRow> fdrlist = new ArrayList<FdrRow>();
    317458    List<FdrRow> reverselist = new ArrayList<FdrRow>();
    318459    // Check if both Tandem and Mascot results
    319     boolean mascot=false, tandem=false;
     460    boolean mascot = false, tandem = false;
     461    // Sequence without modifications (used for peptides only)
     462    String seqstart = "";
    320463    while (resit.hasNext())
    321464    {
    322       ResultRow row=(ResultRow) resit.next();
     465      ResultRow row = (ResultRow) resit.next();
     466      if (!isProteinScores)
     467      {
     468        seqstart = row.description;
     469        if (seqstart.contains(" "))
     470        {
     471          seqstart = seqstart.substring(0, seqstart.indexOf(' '));
     472        }
     473      }
    323474      // spot count
    324       if (row.spotId!=lastSpotId)
     475      if (row.spotId != lastSpotId)
    325476      {
    326477        spots++;
    327         lastSpotId=row.spotId;
     478        lastSpotId = row.spotId;
    328479      }
    329480      // First try to find it in list or add new row
    330       Iterator<FdrRow> fdrit=fdrlist.iterator();
     481      Iterator<FdrRow> fdrit = fdrlist.iterator();
    331482      if (!row.proteinId.startsWith(reverseText))
    332483      {
    333         fdrit=fdrlist.iterator();
     484        fdrit = fdrlist.iterator();
    334485      }
    335486      else
    336487      {
    337         fdrit=reverselist.iterator();
    338       }
    339       boolean foundrow=false;
    340       FdrRow addtorow=new FdrRow();
     488        fdrit = reverselist.iterator();
     489      }
     490      boolean foundrow = false;
     491      FdrRow addtorow = new FdrRow();
    341492      while (!foundrow && fdrit.hasNext())
    342493      {
    343         FdrRow currentfdrrow=fdrit.next();
    344         if (currentfdrrow.spotId==row.spotId)
    345         {
    346           if (row.proteinId.startsWith(currentfdrrow.ipi))
    347           {
    348             foundrow=true;
    349             addtorow=currentfdrrow;
     494        FdrRow currentfdrrow = fdrit.next();
     495        if (currentfdrrow.spotId == row.spotId)
     496        {
     497          if (isProteinScores)
     498          {
     499            if (row.proteinId.startsWith(currentfdrrow.ipi))
     500            {
     501              foundrow = true;
     502              addtorow = currentfdrrow;
     503              fdrit.remove();
     504            }
     505          }
     506          /*
     507           * For peptides the row.mw is actually the spectrum ID. If
     508           * the spectrum Id and the sequence are equal we guess it is
     509           * the same result
     510           */
     511          else if (currentfdrrow.description.startsWith(seqstart) && row.mw == currentfdrrow.mw)
     512          {
     513            foundrow = true;
     514            addtorow = currentfdrrow;
    350515            fdrit.remove();
    351516          }
    352517        }
    353518      }
    354       addtorow.mw=row.mw;
    355       addtorow.pi=row.pi;
    356       addtorow.ipi=row.proteinId;
    357       addtorow.description=row.description;
    358       addtorow.spotId=row.spotId;
     519      addtorow.mw = row.mw;
     520      addtorow.pi = row.pi;
     521      addtorow.ipi = row.proteinId;
     522      addtorow.description = row.description;
     523      addtorow.spotId = row.spotId;
    359524      // Now add score to list
    360525      if (row.score_type.startsWith("Mascot"))
    361526      {
    362         addtorow.mascot_score=row.score;
    363         mascot=true;
    364       } 
     527        addtorow.mascot_score = row.score;
     528        mascot = true;
     529      }
    365530      else
    366531      // Tandem result
    367532      {
    368         addtorow.tandem_eValue=row.eValue;
    369         tandem=true;
     533        addtorow.tandem_eValue = row.eValue;
     534        tandem = true;
    370535      }
    371536      if (!row.proteinId.startsWith(reverseText))
     
    378543      }
    379544    }
    380     Iterator<FdrRow> fdrit=fdrlist.iterator();
     545    Iterator<FdrRow> fdrit = fdrlist.iterator();
    381546    // Now we want to calcluate the p_values
    382     int total_number=db_entries/2*spots;
    383     int reverse_total=reverselist.size();
    384     int forward_total=fdrlist.size();
     547    int total_number = db_entries / 2 * spots;
     548    int reverse_total = reverselist.size();
     549    int forward_total = fdrlist.size();
    385550    while (fdrit.hasNext())
    386551    {
    387       FdrRow currentrow= fdrit.next();
    388       int scores_above=0;
    389       Iterator<FdrRow> reverseit=reverselist.iterator();
    390       // Count how many reverse hits have both scores better, or the score if only one given
     552      FdrRow currentrow = fdrit.next();
     553      int scores_above = 0;
     554      Iterator<FdrRow> reverseit = reverselist.iterator();
     555      // Count how many reverse hits have both scores better, or the score
     556      // if only one given
    391557      while (reverseit.hasNext())
    392558      {
    393         boolean hit_above=false;
    394         FdrRow currentreverse=reverseit.next();
    395         if (currentrow.mascot_score!=0 && currentrow.tandem_eValue!=0)
    396         {
    397         //Both scores to compare
    398           if (currentreverse.mascot_score!=0 && currentreverse.tandem_eValue!=0)
    399           {
    400             if (currentreverse.mascot_score>=currentrow.mascot_score && currentreverse.tandem_eValue<=currentrow.tandem_eValue)
    401             {
    402               hit_above=true;
    403             }
    404           } 
     559        boolean hit_above = false;
     560        FdrRow currentreverse = reverseit.next();
     561        if (currentrow.mascot_score != 0 && currentrow.tandem_eValue != 0)
     562        {
     563          // Both scores to compare
     564          if (currentreverse.mascot_score != 0 && currentreverse.tandem_eValue != 0)
     565          {
     566            if (currentreverse.mascot_score >= currentrow.mascot_score && currentreverse.tandem_eValue <= currentrow.tandem_eValue)
     567            {
     568              hit_above = true;
     569            }
     570          }
    405571        }
    406572        // only one score!
    407         else 
    408         {
    409           if (currentrow.mascot_score!=0 && currentreverse.mascot_score!=0)
    410           { 
    411           // Only compare mascot score
    412             if (currentreverse.mascot_score>=currentrow.mascot_score)
    413             {
    414               hit_above=true;
    415             }
    416           } 
    417           else if (currentrow.tandem_eValue!=0 && currentreverse.tandem_eValue!=0)
     573        else
     574        {
     575          if (currentrow.mascot_score != 0 && currentreverse.mascot_score != 0)
     576          {
     577            // Only compare mascot score
     578            if (currentreverse.mascot_score >= currentrow.mascot_score)
     579            {
     580              hit_above = true;
     581            }
     582          }
     583          else if (currentrow.tandem_eValue != 0 && currentreverse.tandem_eValue != 0)
    418584          // Only tandem score
    419           { 
    420             if (currentreverse.tandem_eValue<=currentrow.tandem_eValue)
    421             {
    422               hit_above=true;
    423             }
    424           }
    425         } 
     585          {
     586            if (currentreverse.tandem_eValue <= currentrow.tandem_eValue)
     587            {
     588              hit_above = true;
     589            }
     590          }
     591        }
    426592        if (hit_above)
    427593        {
    428594          scores_above++;
    429595        }
    430       } 
    431       currentrow.pValue=(double)(scores_above+1)/(double)(total_number+1);
     596      }
     597      currentrow.pValue = (double) (scores_above + 1) / (double) (total_number + 1);
    432598    }
    433599    SortedSet<FdrRow> hitlist = new TreeSet<FdrRow>(fdrlist);
    434     System.out.println("Forward proteins to consider:"+hitlist.size());
    435     FdrRow[] fdrarray=hitlist.toArray(new FdrRow[0]);
    436     // Now all the forward hits are in fdrarray, sorted with ascending p_values
    437     // To correct for multiple possibilities we multiply by the number of search engines
     600    System.out.println("Forward proteins to consider:" + hitlist.size());
     601    FdrRow[] fdrarray = hitlist.toArray(new FdrRow[0]);
     602    // Now all the forward hits are in fdrarray, sorted with ascending
     603    // p_values
     604    // To correct for multiple possibilities we multiply by the number of
     605    // search engines
    438606    if (mascot && tandem)
    439607    {
    440       score_types=2;
    441     }
    442     for (int i=0;i<fdrarray.length;++i)
    443     {
    444       fdrarray[i].corrected_p=score_types*fdrarray[i].pValue*((double) total_number)/(((double)(i+1)));
    445     }
    446     for (int i=0;i<fdrarray.length;++i)
    447     {
    448       double min=1;
    449       for (int j=i;j<fdrarray.length;++j)
    450       {
    451         if (fdrarray[j].corrected_p<min)
    452         {
    453           min=fdrarray[j].corrected_p;
    454         }
    455       }
    456       fdrarray[i].fdr=min;
    457       /* for debugging:
    458       System.out.print("mascot:"+fdrarray[i].mascot_score+" tandem:"+fdrarray[i].tandem_eValue);
    459       System.out.println(" p_value:"+fdrarray[i].pValue+" corrected:"+fdrarray[i].corrected_p+" fdr:"+fdrarray[i].fdr);
    460       */
    461     }
    462     int truecount=0, falsecount=0, tandem_count=0, mascot_count=0,combined_count=0;
    463     double tandem_only_limit=0,mascot_only_limit=1000,tandem_combined=0,mascot_combined=1000;
    464     FdrRow lasthit=fdrarray[0];
     608      score_types = 2;
     609    }
     610    for (int i = 0; i < fdrarray.length; ++i)
     611    {
     612      fdrarray[i].corrected_p = score_types * fdrarray[i].pValue * ((double) total_number) / (((double) (i + 1)));
     613    }
     614    for (int i = 0; i < fdrarray.length; ++i)
     615    {
     616      double min = 1;
     617      for (int j = i; j < fdrarray.length; ++j)
     618      {
     619        if (fdrarray[j].corrected_p < min)
     620        {
     621          min = fdrarray[j].corrected_p;
     622        }
     623      }
     624      fdrarray[i].fdr = min;
     625      /*
     626       * for debugging:
     627       * System.out.print("mascot:"+fdrarray[i].mascot_score+"
     628       * tandem:"+fdrarray[i].tandem_eValue); System.out.println("
     629       * p_value:"+fdrarray[i].pValue+"
     630       * corrected:"+fdrarray[i].corrected_p+" fdr:"+fdrarray[i].fdr);
     631       */
     632    }
     633    int truecount = 0, falsecount = 0, tandem_count = 0, mascot_count = 0, combined_count = 0;
     634    double tandem_only_limit = 0, mascot_only_limit = 1000, tandem_combined = 0, mascot_combined = 1000;
     635    FdrRow lasthit = fdrarray[0];
    465636    SortedSet final_result = new TreeSet();
    466     for (int i=0;i<fdrarray.length;++i)
    467     {
    468       if (fdrarray[i].fdr<=this.getCutOff())
    469       {
    470         ResultRow newrow=new ResultRow();
    471         newrow.spotId=fdrarray[i].spotId;
    472         newrow.proteinId=fdrarray[i].ipi;
    473         newrow.description=fdrarray[i].description;
    474         newrow.eValue=fdrarray[i].tandem_eValue;
    475         newrow.score=fdrarray[i].mascot_score;
    476         newrow.pi=fdrarray[i].pi;
    477         newrow.mw=fdrarray[i].mw;
     637    for (int i = 0; i < fdrarray.length; ++i)
     638    {
     639      if (fdrarray[i].fdr <= this.getCutOff())
     640      {
     641        ResultRow newrow = new ResultRow();
     642        newrow.spotId = fdrarray[i].spotId;
     643        newrow.proteinId = fdrarray[i].ipi;
     644        newrow.description = fdrarray[i].description;
     645        newrow.eValue = fdrarray[i].tandem_eValue;
     646        newrow.score = fdrarray[i].mascot_score;
     647        newrow.pi = fdrarray[i].pi;
     648        newrow.mw = fdrarray[i].mw;
    478649        final_result.add(newrow);
    479650        truecount++;
    480         lasthit=fdrarray[i];
     651        lasthit = fdrarray[i];
    481652        // We want to report the worst scores that passed the FDR
    482         if (fdrarray[i].mascot_score!=0)
    483         {
    484           if (fdrarray[i].tandem_eValue==0)
     653        if (fdrarray[i].mascot_score != 0)
     654        {
     655          if (fdrarray[i].tandem_eValue == 0)
    485656          {
    486657            mascot_count++;
    487             if (mascot_only_limit>fdrarray[i].mascot_score)
    488             {
    489               mascot_only_limit=fdrarray[i].mascot_score;
    490             }
    491           }
    492           else 
     658            if (mascot_only_limit > fdrarray[i].mascot_score)
     659            {
     660              mascot_only_limit = fdrarray[i].mascot_score;
     661            }
     662          }
     663          else
    493664          {
    494665            combined_count++;
    495666            // For combined hits we keep the lowest of any
    496             if (mascot_combined>fdrarray[i].mascot_score)
    497             {
    498               mascot_combined=fdrarray[i].mascot_score;
    499             }
    500             if (tandem_combined<fdrarray[i].tandem_eValue) 
    501             {
    502               tandem_combined=fdrarray[i].tandem_eValue;
    503             }
    504           } 
     667            if (mascot_combined > fdrarray[i].mascot_score)
     668            {
     669              mascot_combined = fdrarray[i].mascot_score;
     670            }
     671            if (tandem_combined < fdrarray[i].tandem_eValue)
     672            {
     673              tandem_combined = fdrarray[i].tandem_eValue;
     674            }
     675          }
    505676        }
    506677        else
    507678        {
    508679          tandem_count++;
    509           if (tandem_only_limit<fdrarray[i].tandem_eValue)
    510           {
    511             tandem_only_limit=fdrarray[i].tandem_eValue;
    512           } 
     680          if (tandem_only_limit < fdrarray[i].tandem_eValue)
     681          {
     682            tandem_only_limit = fdrarray[i].tandem_eValue;
     683          }
    513684        }
    514685      }
     
    518689      }
    519690    }
    520     System.out.println("Worst hit fdr:"+lasthit.fdr+" pValue:"+lasthit.pValue+ " corrected:"+lasthit.corrected_p+" spot+ipi:"+lasthit.spotId+" "+lasthit.ipi);
    521     System.out.println("Lowest mascot only score:"+mascot_only_limit+" Tandem:"+tandem_only_limit);
    522     System.out.println("Lowest scores in combined. Mascot:"+mascot_combined+" tandem:"+tandem_combined);
    523     System.out.println("Positives:"+truecount+" Combined:"+combined_count+" tandem:"+tandem_count+" mascot:"+mascot_count);
    524     // now count false tandem and mascot hits in order to find out if OK. Print the reverse db hits.
    525 
    526     int mascot_scores_above=0,tandem_scores_below=0, both_scores=0;
    527     Iterator<FdrRow> reverse_it=reverselist.iterator();
     691    System.out
     692      .println("Worst hit fdr:" + lasthit.fdr + " pValue:" + lasthit.pValue + " corrected:" + lasthit.corrected_p + " spot+ipi:" + lasthit.spotId + " " + lasthit.ipi);
     693    System.out
     694      .println("Lowest mascot only score:" + mascot_only_limit + " Tandem:" + tandem_only_limit);
     695    System.out
     696      .println("Lowest scores in combined. Mascot:" + mascot_combined + " tandem:" + tandem_combined);
     697    System.out
     698      .println("Positives:" + truecount + " Combined:" + combined_count + " tandem:" + tandem_count + " mascot:" + mascot_count);
     699    // now count false tandem and mascot hits in order to find out if OK.
     700    // Print the reverse db hits.
     701    int mascot_scores_above = 0, tandem_scores_below = 0, both_scores = 0;
     702    Iterator<FdrRow> reverse_it = reverselist.iterator();
    528703    System.out.println("Random DB hits passing:");
    529704    while (reverse_it.hasNext())
    530705    {
    531       FdrRow currentrow=reverse_it.next();
    532       if ((currentrow.mascot_score!=0) && (currentrow.tandem_eValue==0))
    533       {
    534         if (currentrow.mascot_score>=mascot_only_limit)
     706      FdrRow currentrow = reverse_it.next();
     707      if ((currentrow.mascot_score != 0) && (currentrow.tandem_eValue == 0))
     708      {
     709        if (currentrow.mascot_score >= mascot_only_limit)
    535710        {
    536711          mascot_scores_above++;
    537           System.out.println("spot+accession:"+currentrow.spotId+" "+currentrow.ipi+" mascot:"+currentrow.mascot_score);
    538         }
    539       }
    540       else if ((currentrow.mascot_score==0) && (currentrow.tandem_eValue!=0))
    541       {
    542         if (currentrow.tandem_eValue<=tandem_only_limit)
     712          System.out
     713            .println("spot+accession:" + currentrow.spotId + " " + currentrow.ipi + " mascot:" + currentrow.mascot_score);
     714        }
     715      }
     716      else if ((currentrow.mascot_score == 0) && (currentrow.tandem_eValue != 0))
     717      {
     718        if (currentrow.tandem_eValue <= tandem_only_limit)
    543719        {
    544720          tandem_scores_below++;
    545           System.out.println("spot+accession:"+currentrow.spotId+" "+currentrow.ipi+" tandem:"+currentrow.tandem_eValue);
    546         }
    547       }
    548       else if ((currentrow.mascot_score!=0) && (currentrow.tandem_eValue!=0))
    549       {
    550         if (currentrow.tandem_eValue<=tandem_combined && currentrow.mascot_score>=mascot_combined)
     721          System.out
     722            .println("spot+accession:" + currentrow.spotId + " " + currentrow.ipi + " tandem:" + currentrow.tandem_eValue);
     723        }
     724      }
     725      else if ((currentrow.mascot_score != 0) && (currentrow.tandem_eValue != 0))
     726      {
     727        if (currentrow.tandem_eValue <= tandem_combined && currentrow.mascot_score >= mascot_combined)
    551728        {
    552729          // This one is tricky, since the score limit is a curve
    553           // We have to calculate a p-value for the reverse hit as we did for
    554           // the forward hits and find out if it is lower than the limit.
    555           Iterator<FdrRow> reverseit=reverselist.iterator();
    556           int reversehits=0;
     730          // We have to calculate a p-value for the reverse hit as we
     731          // did for
     732          // the forward hits and find out if it is lower than the
     733          // limit.
     734          Iterator<FdrRow> reverseit = reverselist.iterator();
     735          int reversehits = 0;
    557736          // Count how many reverse hits have both scores better
    558737          while (reverseit.hasNext())
    559738          {
    560             FdrRow currentreverse=reverseit.next();
    561             if (currentreverse.mascot_score!=0 && currentreverse.tandem_eValue!=0)
    562             {
    563               if (currentreverse.mascot_score>=currentrow.mascot_score && currentreverse.tandem_eValue<=currentrow.tandem_eValue)
     739            FdrRow currentreverse = reverseit.next();
     740            if (currentreverse.mascot_score != 0 && currentreverse.tandem_eValue != 0)
     741            {
     742              if (currentreverse.mascot_score >= currentrow.mascot_score && currentreverse.tandem_eValue <= currentrow.tandem_eValue)
    564743              {
    565744                reversehits++;
     
    567746            }
    568747          }
    569           currentrow.pValue=(double)(reversehits+1)/(double)(total_number+1);
    570           if (currentrow.pValue<lasthit.pValue)
     748          currentrow.pValue = (double) (reversehits + 1) / (double) (total_number + 1);
     749          if (currentrow.pValue < lasthit.pValue)
    571750          {
    572751            both_scores++;
    573             System.out.println("spot+accession:"+currentrow.spotId+" "+currentrow.ipi+" tandem:"+currentrow.tandem_eValue+" mascot:"+currentrow.mascot_score);
    574           }
    575         }
    576       }
    577     }
    578     info = "FPR:"+cutOff+" Tandem only limit:"+tandem_only_limit+" Mascot only limit:"+mascot_only_limit+". Worst scores passing in combined hits: (Tandem, Mascot):"+tandem_combined+", "+mascot_combined;
    579     info += ". Hits passing:"+truecount+" Tandem:"+tandem_count+" Mascot:"+mascot_count+" Combined:"+combined_count;
    580     info += ". Reverse db hits passing - Tandem:"+tandem_scores_below+" Mascot:"+mascot_scores_above+" Combined:"+both_scores;
    581     System.out.println("Reverse mascot above:"+mascot_scores_above);
    582     System.out.println("Reverse tandem below:"+tandem_scores_below);
    583     System.out.println("Reverse both:"+both_scores);
    584  
     752            System.out
     753              .println("spot+accession:" + currentrow.spotId + " " + currentrow.ipi + " tandem:" + currentrow.tandem_eValue + " mascot:" + currentrow.mascot_score);
     754          }
     755        }
     756      }
     757    }
     758    info = "FPR:" + cutOff + " Tandem only limit:" + tandem_only_limit + " Mascot only limit:" + mascot_only_limit + ". Worst scores passing in combined hits: (Tandem, Mascot):" + tandem_combined + ", " + mascot_combined;
     759    info += ". Hits passing:" + truecount + " Tandem:" + tandem_count + " Mascot:" + mascot_count + " Combined:" + combined_count;
     760    info += ". Reverse db hits passing - Tandem:" + tandem_scores_below + " Mascot:" + mascot_scores_above + " Combined:" + both_scores;
     761    System.out.println("Reverse mascot above:" + mascot_scores_above);
     762    System.out.println("Reverse tandem below:" + tandem_scores_below);
     763    System.out.println("Reverse both:" + both_scores);
    585764    return final_result;
    586765  }
    587  
     766
     767
    588768  public void setDate(String date)
    589769  {
    590770    this.date = date;
    591771  }
     772
     773
    592774  public String getDate()
    593775  {
    594776    return date;
    595777  }
    596  
     778
     779
    597780  public void setDate2(String date2)
    598781  {
    599782    this.date2 = date2;
    600783  }
     784
     785
    601786  public String getDate2()
    602787  {
    603788    return date2;
    604789  }
     790
     791
    605792  public void setReverseText(String reverseText)
    606793  {
    607794    this.reverseText = reverseText;
    608795  }
     796
     797
    609798  public String getReverseText()
    610799  {
    611800    return reverseText;
    612801  }
    613  
     802
     803
     804  public void setIsProteinScores(boolean isproteins)
     805  {
     806    this.isProteinScores = isproteins;
     807  }
     808
     809
    614810  public void setCutOff(Double cutOff)
    615811  {
    616812    this.cutOff = cutOff.doubleValue();
    617813  }
     814
     815
    618816  public Double getCutOff()
    619817  {
    620818    return new Double(cutOff);
    621819  }
    622  
     820
    623821  public class FdrRow
    624     implements Comparable
     822      implements Comparable
    625823  {
    626824    FdrRow()
    627     {
    628     }
     825    {}
     826
    629827
    630828    public int compareTo(Object o)
    631829    {
    632       int retval=1;
    633       FdrRow other = (FdrRow)o;
    634       if (this.pValue<other.pValue)
    635       {
    636         retval=-1;
    637       }
    638       else if (this.pValue==other.pValue)
    639       {
    640         if (this.spotId==other.spotId)
    641         {
    642           retval=this.ipi.compareTo(other.ipi);
    643         }
    644         else if (this.spotId<other.spotId)
    645         {
    646           retval=-1;
     830      int retval = 1;
     831      FdrRow other = (FdrRow) o;
     832      if (this.pValue < other.pValue)
     833      {
     834        retval = -1;
     835      }
     836      else if (this.pValue == other.pValue)
     837      {
     838        if (this.spotId == other.spotId)
     839        {
     840          retval = this.ipi.compareTo(other.ipi);
     841        }
     842        else if (this.spotId < other.spotId)
     843        {
     844          retval = -1;
    647845        }
    648846      }
     
    650848    }
    651849
    652     public double pValue=1;
     850    public double pValue = 1;
    653851    public double fdr;
    654     public int spotId=0;
    655     public String ipi="";
     852    public int spotId = 0;
     853    public String ipi = "";
    656854    public String description;
    657     public double mascot_score=0;
    658     public double tandem_eValue=0;
     855    public double mascot_score = 0;
     856    public double tandem_eValue = 0;
    659857    public double corrected_p;
    660     public double mw=0;
    661     public double pi=0;
    662    
    663 
    664   }
    665  
    666  
     858    public double mw = 0;
     859    public double pi = 0;
     860  }
     861
    667862  /**
    668     This abstract inner class stores data for one row in the report. It also
    669     contains a compareTo method that will sort the objects correct
    670   */
     863   * This abstract inner class stores data for one row in the report. It also
     864   * contains a compareTo method that will sort the objects correct
     865   */
    671866  public class ResultRow
    672     implements Comparable
     867      implements Comparable
    673868  {
    674869    ResultRow()
    675     {
    676     }
    677    
     870    {}
     871
     872
    678873    /**
    679       Comparator that for sorting the objects according to SpotId,
    680       and eValue.
    681      
    682       @param o The object to compare with.
    683     */
     874     * Comparator that for sorting the objects according to SpotId, and
     875     * eValue.
     876     *
     877     * @param o The object to compare with.
     878     */
    684879    public int compareTo(Object o)
    685880    {
    686881      int compValue = 1;
    687       ResultRow other = (ResultRow)o;
     882      ResultRow other = (ResultRow) o;
    688883      if (this.spotId < other.spotId)
    689884      {
    690885        compValue = -1;
    691       } 
    692       else if (this.spotId==other.spotId)
     886      }
     887      else if (this.spotId == other.spotId)
    693888      {
    694889        if (this.eValue < other.eValue)
     
    696891          compValue = -1;
    697892        }
    698         else if (this.eValue==other.eValue && (this.score>other.score))
     893        else if (this.eValue == other.eValue && (this.score > other.score))
    699894        {
    700895          compValue = -1;
    701         }         
     896        }
    702897      }
    703898      return compValue;
    704899    }
    705    
     900
     901
    706902    public String toString()
    707903    {
    708       String out = spotId+"\t"+eValue+"\t"+score+"\t"+proteinId+"\t"+description+"\t"+mw+"\t"+pi;
     904      String out = spotId + "\t" + eValue + "\t" + score + "\t" + proteinId + "\t" + description + "\t" + mw + "\t" + pi;
    709905      return out;
    710906    }
    711    
    712  
     907
    713908    // Variables
    714     public Date dBSearchId=new Date(10000);
    715     public int spotId=0;
     909    public Date dBSearchId = new Date(10000);
     910    public int spotId = 0;
    716911    public String MPId;
    717912    public String MPLabel;
    718913    public String TargetId;
    719914    public String TargetPosition;
    720     public double eValue=1000;
    721     public String proteinId="";
     915    public double eValue = 1000;
     916    public String proteinId = "";
    722917    public String description;
    723     public String score_type="";
    724     public double score=0;
    725     public double mw=0;
    726     public double pi=0;
    727     public double rms=0;
    728     public List identificationHypotheses=new ArrayList();
     918    public String score_type = "";
     919    public double score = 0;
     920    public double mw = 0;
     921    public double pi = 0;
     922    public double rms = 0;
     923    public List identificationHypotheses = new ArrayList();
    729924  }
    730925
    731926  SimpleDateFormat dfXML = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
    732  
    733927  private SQLEvictConnection dbconnection;
    734928  private Set resultSet;
     929  private int db_entries = 0;
    735930  private String gelId;
    736   private String info="";
     931  private String info = "";
    737932  private String date;
    738933  private String date2;
    739934  private String reverseText;
    740   private double cutOff=0.01;
     935  private String gel_autoid;
     936  private boolean isProteinScores = true;
     937  private double cutOff = 0.01;
    741938}
Note: See TracChangeset for help on using the changeset viewer.