Changeset 4269


Ignore:
Timestamp:
Dec 22, 2011, 4:50:55 PM (12 years ago)
Author:
Fredrik Levander
Message:

Refs #772. Updated info reader and hits import.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/api/core/src/org/proteios/core/Hit.java

    r4252 r4269  
    266266  {
    267267    getData().setFractionId(fractionId);
     268  }
     269
     270  /**
     271   * The maximum length of the replicate ID that can be stored in the database.
     272   *
     273   * @see #setReplicateId(String)
     274   */
     275  public static final int MAX_RELICATE_ID_LENGTH = HitData.MAX_REPLICATE_ID_LENGTH;
     276
     277
     278  public String getReplicateId()
     279  {
     280    return getData().getReplicateId();
     281  }
     282
     283
     284  public void setReplicateId(String replicateId)
     285  {
     286    getData().setReplicateId(replicateId);
    268287  }
    269288
  • trunk/api/core/src/org/proteios/core/data/HitData.java

    r3532 r4269  
    4848  private String localSampleId = null;
    4949  private String fractionId = null;
     50  private String replicateId = null;
    5051  private Boolean microPlate = null;
    5152  private Date searchDate = null;
     
    222223  }
    223224
     225  /**
     226   * The maximum length of the replicate ID that can be stored in the database.
     227   *
     228   * @see #setFractionId(String)
     229   */
     230  public static final int MAX_REPLICATE_ID_LENGTH = 10;
     231
     232 
     233  /**
     234   * A replicate id, e.g. a serial number like 01. Constrained to 10 characters.
     235   *
     236   * @hibernate.property column="`replicateId`" length="16" type="string"
     237   *                     not-null="false"
     238   */
     239  public String getReplicateId()
     240  {
     241    return replicateId;
     242  }
     243
     244
     245  public void setReplicateId(String replicateId)
     246  {
     247    this.replicateId = replicateId;
     248  }
     249
    224250
    225251  /**
  • trunk/client/servlet/src/locale/en/dictionary

    r4239 r4269  
    742742Remaining=Remaining
    743743RemainingSampleQuantityInMicroLiters=Remaining Sample Quantity (µl)
     744ReplicateId=Replicate ID
    744745Removed=Removed
    745746Reports=Reports
  • trunk/client/servlet/src/org/proteios/action/file/InfoFileHandler.java

    r4125 r4269  
    298298          annotationName = "fraction";
    299299        }
     300        // To make sure replicate annotation is always lower case
     301        else if (annotationName.equalsIgnoreCase("replicate"))
     302        {
     303          annotationName = "replicate";
     304        }
    300305        AnnotationType at = annotator.getAnnotationType(annotationName,
    301306          Type.STRING, file.getType());
  • trunk/plugin/src/org/proteios/plugins/PeakListToHitNonGelPlugin.java

    r4126 r4269  
    4444import org.proteios.core.Project;
    4545import org.proteios.core.SessionControl;
     46import org.proteios.core.Type;
    4647import org.proteios.core.plugin.About;
    4748import org.proteios.core.plugin.AboutImpl;
     
    5556import org.proteios.io.FilenameParseUtil;
    5657import org.proteios.io.PeakListFileValidationFactory;
     58
    5759import java.util.ArrayList;
    5860import java.util.Collections;
     61import java.util.Iterator;
    5962import java.util.List;
    6063import java.util.Set;
     
    116119    // Directory d = (Directory) job.getValue("dir");
    117120    ArrayList<Throwable> err = new ArrayList<Throwable>(1);
    118     String localSampleIdEntryMode = (String) job.getValue("localSampleIdEntryMode");
    119     log.debug("localSampleIdEntryMode = \"" + localSampleIdEntryMode + "\"");
     121    String localSampleIdEntryMode = (String) job
     122      .getValue("localSampleIdEntryMode");
     123    log
     124      .debug("localSampleIdEntryMode = \"" + localSampleIdEntryMode + "\"");
    120125    String localSampleId = (String) job.getValue("localSampleId");
    121     String fractionIdEntryMode = (String) job.getValue("fractionIdEntryMode");
     126    String fractionIdEntryMode = (String) job
     127      .getValue("fractionIdEntryMode");
    122128    log.debug("fractionIdEntryMode = \"" + fractionIdEntryMode + "\"");
    123129    String regexPattern = (String) job.getValue("regexPattern");
     
    128134    DbControl dc = sc.newDbControl();
    129135    Project project = Project.getById(dc, sc.getActiveProjectId());
    130     List<FileType> fts = PeakListFileValidationFactory.getPossibleFileTypes(dc);
     136    List<FileType> fts = PeakListFileValidationFactory
     137      .getPossibleFileTypes(dc);
    131138    dc.reattachItem(f);
    132139    //
    133140    List<String> localSampleIdStringList = new ArrayList<String>();
    134141    Set<BioMaterial> fileBioMaterialSet = f.getBioMaterials();
    135     for (BioMaterial fileBioMaterial: fileBioMaterialSet)
     142    for (BioMaterial fileBioMaterial : fileBioMaterialSet)
    136143    {
    137144      String fileBioMaterialName = fileBioMaterial.getName();
     
    142149        localSampleIdStringList.add(fileBioMaterialName);
    143150      }
    144       else if (fileBioMaterialName2 != null && !fileBioMaterialName2.equals(""))
     151      else if (fileBioMaterialName2 != null && !fileBioMaterialName2
     152        .equals(""))
    145153      {
    146154        // Add name to local sample id string list
     
    148156      }
    149157    }
    150     if (localSampleIdEntryMode.equals(GET_LOCAL_SAMPLE_ID_FROM_FILE_BIOMATERIAL))
    151     {
    152       if (localSampleIdStringList != null && localSampleIdStringList.size() != 0)
     158    if (localSampleIdEntryMode
     159      .equals(GET_LOCAL_SAMPLE_ID_FROM_FILE_BIOMATERIAL))
     160    {
     161      if (localSampleIdStringList != null && localSampleIdStringList
     162        .size() != 0)
    153163      {
    154164        // Sort combined list
    155165        Collections.sort(localSampleIdStringList);
    156166        String tmpLocalSampleId = new String("");
    157         for (String partStr: localSampleIdStringList)
     167        for (String partStr : localSampleIdStringList)
    158168        {
    159169          if (partStr != null && !partStr.equals(""))
     
    190200    if (ft != null && (fts.contains(ft)))
    191201    {
     202      // Retrieve replicate ID
     203      String replicate = fetchReplicateIdFromFileAnnotation(dc, f);
    192204      // Attempt to obtain fraction ID from file annotation "fraction".
    193       String fractionIdFromAnnotation = fetchFractionIdFromFileAnnotation(dc, f);
     205      String fractionIdFromAnnotation = fetchFractionIdFromFileAnnotation(
     206        dc, f);
    194207      // Use regex pattern to parse fraction ID from filename
    195208      String fractionIdFromFilename = null;
     
    197210      {
    198211        // Use regex pattern to parse fraction ID from filename
    199         fractionIdFromFilename = fpu.fetchRegexResult(f.getName(), regexPattern);
    200       }
    201       log.debug("fraction id from file annotation = \"" + fractionIdFromAnnotation + "\"");
    202       log.debug("fraction id from file name = \"" + fractionIdFromFilename + "\"");
     212        fractionIdFromFilename = fpu.fetchRegexResult(f.getName(),
     213          regexPattern);
     214      }
     215      log
     216        .debug("fraction id from file annotation = \"" + fractionIdFromAnnotation + "\"");
     217      log
     218        .debug("fraction id from file name = \"" + fractionIdFromFilename + "\"");
    203219      // Get fraction id, if any
    204220      String fractionId = new String("");
    205       if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION)
    206           || fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME))
     221      if (fractionIdEntryMode
     222        .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION) || fractionIdEntryMode
     223        .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME))
    207224      {
    208225        if (fractionIdFromAnnotation != null)
    209226        {
    210           // First choice, fraction id from annotation for peaklist file
     227          // First choice, fraction id from annotation for peaklist
     228          // file
    211229          fractionId = fractionIdFromAnnotation;
    212230        }
    213         else if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME))
     231        else if (fractionIdEntryMode
     232          .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_ANNOTATION_OR_NAME))
    214233        {
    215234          if (fractionIdFromFilename != null)
     
    220239        }
    221240      }
    222       else if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME)
    223           || fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION))
     241      else if (fractionIdEntryMode
     242        .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME) || fractionIdEntryMode
     243        .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION))
    224244      {
    225245        if (fractionIdFromFilename != null)
     
    228248          fractionId = fractionIdFromFilename;
    229249        }
    230         else if (fractionIdEntryMode.equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION))
     250        else if (fractionIdEntryMode
     251          .equals(GET_FRACTION_ID_FROM_PEAKLIST_FILE_NAME_OR_ANNOTATION))
    231252        {
    232253          if (fractionIdFromAnnotation != null)
    233254          {
    234             // Second choice, fraction id from annotation for peaklist file
     255            // Second choice, fraction id from annotation for
     256            // peaklist file
    235257            fractionId = fractionIdFromAnnotation;
    236258          }
     
    242264      if (fractionId != null && fractionId.length() > Hit.MAX_FRACTION_ID_LENGTH)
    243265      {
    244         log.debug("Fraction ID = \"" + fractionId + "\" is too long (" + fractionId.length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed).");
    245         err.add(new BaseException(
    246           "Fraction ID = \"" + fractionId + "\" is too long (" + fractionId.length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed)."));
     266        log
     267          .debug("Fraction ID = \"" + fractionId + "\" is too long (" + fractionId
     268            .length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed).");
     269        err
     270          .add(new BaseException(
     271            "Fraction ID = \"" + fractionId + "\" is too long (" + fractionId
     272              .length() + " characters, " + Hit.MAX_FRACTION_ID_LENGTH + " allowed)."));
    247273        response.setError("Nothing imported", err);
    248274        return;
     
    281307        newhit.setLocalSampleId(localSampleId);
    282308        newhit.setFractionId(fractionId);
     309        if (replicate !=null)
     310        {
     311          newhit.setReplicateId(replicate);
     312        }
    283313        dc.saveItem(newhit);
    284314        dc.reattachItem(newhit);
     
    325355
    326356  /*
     357   * Attempts to obtain replicate id from file annotation "replicate".
     358   * @param DbControl dc The DbControl to use.
     359   * @param File file The file to get the annotation for.
     360   * @return String The found fraction id, or null if none found.
     361   */
     362  private String fetchReplicateIdFromFileAnnotation(DbControl dc, File file)
     363  {
     364    String replicateId = null;
     365    Annotator annotator = new Annotator(new ItemFactory(dc));
     366    AnnotationType at = annotator.getAnnotationType(file, "replicate", Type.STRING);
     367    Annotation annotation = annotator.getAnnotation(file, at);
     368    Iterator<?> it = annotation.getValues().iterator();
     369    while (it.hasNext())
     370    {
     371      replicateId = (String) it.next();
     372    }
     373    return replicateId;
     374  }
     375
     376
     377  /*
    327378   * Attempts to obtain fraction id from file annotation "fraction".
    328    *
    329379   * @param DbControl dc The DbControl to use.
    330380   * @param File file The file to get the anntation for.
     
    336386    // Try to get fraction id from file annotation "fraction"
    337387    Annotator annotator = new Annotator(new ItemFactory(dc));
    338     ItemQuery<Annotation> annotationQuery = annotator.getAnnotationSet(file).getAnnotations();
     388    ItemQuery<Annotation> annotationQuery = annotator
     389      .getAnnotationSet(file).getAnnotations();
    339390    ItemResultList<Annotation> annotationList = annotationQuery.list(dc);
    340391    if (annotationList != null && annotationList.size() > 0)
    341392    {
    342       for (Annotation annotation: annotationList)
     393      for (Annotation annotation : annotationList)
    343394      {
    344395        if (annotation != null)
    345396        {
    346397          // Get annotation type
    347           AnnotationType annotationType = annotation.getAnnotationType();
     398          AnnotationType annotationType = annotation
     399            .getAnnotationType();
    348400          if (annotationType != null)
    349401          {
    350402            String annotationTypeName = annotationType.getName();
    351             if (annotationTypeName != null && annotationTypeName.equals("fraction"))
     403            if (annotationTypeName != null && annotationTypeName
     404              .equals("fraction"))
    352405            {
    353               List<String> tmpFractionIdList = (List<String>) annotation.getValues();
    354               if (tmpFractionIdList != null && tmpFractionIdList.size() > 0)
     406              List<String> tmpFractionIdList = (List<String>) annotation
     407                .getValues();
     408              if (tmpFractionIdList != null && tmpFractionIdList
     409                .size() > 0)
    355410              {
    356                 String tmpFractionId = (String) tmpFractionIdList.get(0);
    357                 if (tmpFractionId != null && !tmpFractionId.equals(""))
     411                String tmpFractionId = (String) tmpFractionIdList
     412                  .get(0);
     413                if (tmpFractionId != null && !tmpFractionId
     414                  .equals(""))
    358415                {
    359416                  fractionId = tmpFractionId;
  • trunk/plugin/src/org/proteios/plugins/SearchResultsImporter.java

    r4261 r4269  
    221221              hit.setLocalSampleId(emptyHit.getLocalSampleId());
    222222              hit.setFractionId(emptyHit.getFractionId());
     223              hit.setReplicateId(emptyHit.getReplicateId());
    223224              hit.setPeakListFile(emptyHit.getPeakListFile());
    224225              dc.saveItem(hit);
Note: See TracChangeset for help on using the changeset viewer.