Changeset 4563


Ignore:
Timestamp:
Apr 10, 2015, 3:41:16 PM (8 years ago)
Author:
Fredrik Levander
Message:

Updated tab feature importer to support new feature format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugin/src/org/proteios/plugins/TabFeatureImporter.java

    r4559 r4563  
    5959
    6060/**
    61  * This plug-in reads a features.tsv file and imports it into the
    62  * features table.
     61 * This plug-in reads a features.tsv file and imports it into the features
     62 * table.
    6363 *
    6464 * @author fredrik
     
    7272  private static final org.apache.log4j.Logger log = org.apache.log4j.LogManager
    7373    .getLogger("org.proteios.io");
    74  
     74
    7575
    7676  public TabFeatureImporter()
     
    8989  {
    9090    return new AboutImpl("Tab feature importer",
    91       "Import of tab separated features to database", "0.1",
    92       "2010, Fredrik Levander", null, null,
    93       "http://www.proteios.org");
     91      "Import of tab separated features to database", "0.2",
     92      "2010-2015, Fredrik Levander", null, null, "http://www.proteios.org");
    9493  }
    9594
     
    121120      {
    122121        ItemQuery<Feature> featureQuery = qf.select(Feature.class);
    123         featureQuery.restrict(Restrictions.eq(Hql
    124           .property("featureFile"), Hql.entity(featureFile)));
     122        featureQuery.restrict(Restrictions.eq(
     123          Hql.property("featureFile"), Hql.entity(featureFile)));
    125124        if (featureQuery.count(dc) > 0)
    126125        {
     
    162161              index[6] = line.indexOf("intensity");
    163162              index[7] = line.indexOf("intensity");
    164               if (line.indexOf("IntegratedIntensity")>1)
     163              if (line.indexOf("IntegratedIntensity") > 1)
    165164              {
    166165                index[7] = line.indexOf("IntegratedIntensity");
    167166              }
     167              // For Dinosaur feature format:
     168              if (index[0] < 1)
     169                index[0] = line.indexOf("rtApex");
     170              if (index[1] < 1)
     171                index[1] = line.indexOf("monoisoMz");
     172              if (index[2] < 1)
     173                index[2] = line.indexOf("rtStart");
     174              if (index[5] < 1)
     175                index[5] = line.indexOf("rtEnd");
     176              if (index[6] < 1)
     177                index[6] = line.indexOf("intensityApex");
     178              if (index[7] < 1)
     179                index[7] = line.indexOf("intensitySum");
    168180              featureStart = true;
    169181            }
     
    187199              feature.setApexIntensity(Float.valueOf(line
    188200                .get(index[6])));
    189               feature.setStartRetentionTimeInMinutes(Float.valueOf(line.get(index[2])));
    190               feature.setEndRetentionTimeInMinutes(Float.valueOf(line.get(index[5])));
     201              feature.setStartRetentionTimeInMinutes(Float
     202                .valueOf(line.get(index[2])));
     203              feature.setEndRetentionTimeInMinutes(Float
     204                .valueOf(line.get(index[5])));
    191205              feature.setFeatureFile(featureFile);
    192206              feature.setMsFile(mzXMLFile);
     
    204218        {
    205219          throw new BaseException(
    206             "Not a valid tab-separated feature file. First line should start with '# algorithm=F' or '# algorithm=M'");
     220            "Not a valid tab-separated feature file. First line should start with '# algorithm=F','# algorithm=M', 'monoisoMz' or 'mz'");
    207221        }
    208222      }
     
    270284    else if (fileName.contains(".features"))
    271285    {
    272       searchString = fileName.substring(0, fileName
    273         .lastIndexOf(".features")) + ".mzML";
     286      searchString = fileName.substring(0,
     287        fileName.lastIndexOf(".features")) + ".mzML";
    274288    }
    275289    if (searchString != null)
     
    296310
    297311
    298  
    299312  // ----------------------------------------------------------
    300313  /*
     
    317330      if ((line = inreader.readLine()) != null)
    318331      {
    319         ok = (line.startsWith("mz") || line.startsWith("# algorithm=M") || line.startsWith("# algorithm=F"));
     332        ok = (line.startsWith("monoisoMz") || line.startsWith("mz") || line
     333          .startsWith("# algorithm=M") || line
     334          .startsWith("# algorithm=F"));
    320335      }
    321336      inreader.close();
Note: See TracChangeset for help on using the changeset viewer.