Changeset 6221


Ignore:
Timestamp:
Apr 23, 2021, 9:01:50 AM (2 years ago)
Author:
Nicklas Nordborg
Message:

References #1295: Registration of specimen handled by external lab

Preparations for importing protocol info assuming that we can match the provided value to the ExternalRef annotation of a protocol.

Also some preparations for MD5 if we will get that for the FASTQ files.

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

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/DnaInfo.java

    r6212 r6221  
    3737      // TODO -- concentrations and quantities
    3838      // TODO -- protocol
     39      protocol = section.getRequiredEntry("Protocol", ProtocolValidator.EXTRACTION_PROTOCOL);
    3940    }
    4041    valid = section != null && !section.hasError();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/FastqInfo.java

    r6210 r6221  
    3434      R1 = fastq.getRequiredEntry("R1", new FastqFile());
    3535      R2 = fastq.getRequiredEntry("R2", new FastqFile());
     36      // TODO -- wait and see
     37      if (R1 != null) R1.md5 = fastq.getOptionalEntry("R1 MD5", PatternValidator.MD5);
     38      if (R2 != null) R2.md5 = fastq.getOptionalEntry("R2 MD5", PatternValidator.MD5);
    3639    }
    3740    valid = fastq != null && !fastq.hasError();
     
    7477  {
    7578    public String name;
     79    public String md5;
    7680    public long size;
    7781    public long lastModified;
     
    8589    public FastqFile isValid(DbControl dc, String value, JsonSection section, String entryKey)
    8690    {
    87       this.name = value; // TODO -- implement validation
    88       return this;
     91      this.name = PatternValidator.FILE_NAME.isValid(dc, value, section, entryKey);
     92      if (name != null && !name.endsWith(".fastq.gz"))
     93      {
     94        section.addWarningMessage("FASTQ filename doesn't end with '.fastq.gz': "+entryKey+"="+value);
     95      }
     96      return name == null ? null : this;
    8997    }
    9098   
     
    93101      JSONObject j = new JSONObject();
    94102      j.put("name", name);
     103      j.put("md5", md5);
    95104      j.put("size", size);
    96105      j.put("lastModified", Reggie.CONVERTER_DATETIME_TO_STRING_WITH_SEPARATOR.convert(new Date(lastModified)));
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/FlowThroughInfo.java

    r6212 r6221  
    3636      // TODO -- concentrations and quantities
    3737      // TODO -- protocol
     38      protocol = section.getRequiredEntry("Protocol", ProtocolValidator.EXTRACTION_PROTOCOL);
    3839    }
    3940    valid = section != null && !section.hasError();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LibraryInfo.java

    r6212 r6221  
    7171      barcode = section.getRequiredEntry("Barcode", BarcodeValidator.INSTANCE);
    7272      // TODO -- protocol
     73      protocol = section.getRequiredEntry("Protocol", ProtocolValidator.LIB_PROTOCOL);
    7374    }
    7475    valid = section != null && !section.hasError();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/LysateInfo.java

    r6217 r6221  
    3333      usedFromSpecimen = section.getRequiredEntry("Used quantity (mg)", FloatValidator.POSITIVE);
    3434      // TODO -- protocol
     35      protocol = section.getRequiredEntry("Protocol", ProtocolValidator.SAMPLE_HANDLING_PROTOCOL);
    3536     
    3637      if (specimen.originalQuantity != null && specimen.remainingQuantity != null && usedFromSpecimen != null)
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/PatternValidator.java

    r6217 r6221  
    5555  public static final PatternValidator PAD = new PatternValidator("[A-Z0-9-]{4,20}", "PAD", null, "4-20 characters A-Z, 0-9 or '-'");
    5656 
     57  /**
     58    Filenames are allowed to have A-Z (upper and lower case), 0-9, '-', '_', and '.'.
     59  */
     60  public static final PatternValidator FILE_NAME = new PatternValidator("[a-zA-Z0-9_.-]+", "file name", null, "A-Z, 0-9, '-', '_' or '.'");
     61 
     62  /**
     63    MD5 validator.
     64  */
     65  public static final PatternValidator MD5 = new PatternValidator("[a-f0-9]{32}", "MD5", null, "32 characters, 0-9 or a-f");
     66 
    5767  private final Pattern pattern;
    5868  private final String subject;
     
    7181  public String isValid(DbControl dc, String value, JsonSection section, String entryKey)
    7282  {
    73     Matcher m = pattern.matcher(value);
    74     if (!m.matches())
     83    if (value != null)
    7584    {
    76       section.addErrorMessage("Invalid "+subject+" in JSON: "+entryKey+"="+value+(expected!=null?" (expected " +expected+")":""));
    77       return null;
     85      Matcher m = pattern.matcher(value);
     86      if (!m.matches())
     87      {
     88        section.addErrorMessage("Invalid "+subject+" in JSON: "+entryKey+"="+value+(expected!=null?" (expected " +expected+")":""));
     89        return null;
     90      }
     91      if (replacement != null) value = m.replaceAll(replacement);
    7892    }
    79     if (replacement != null) value = m.replaceAll(replacement);
    8093    return value;
    8194  }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/cmd/RnaInfo.java

    r6212 r6221  
    3939      // TODO -- RNAQC
    4040      // TODO -- protocol
     41      protocol = section.getRequiredEntry("Protocol", ProtocolValidator.EXTRACTION_PROTOCOL);
    4142    }
    4243    valid = section != null && !section.hasError();
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/servlet/InstallServlet.java

    r6219 r6221  
    879879            Annotationtype.SCORE_STROMA, Annotationtype.SCORE_FAT));
    880880       
     881        jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.SAMPLE_HANDLING_PROTOCOL, createIfMissing,
     882            Annotationtype.EXTERNAL_REF
     883            ));
     884
    881885        jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.LYSATE, createIfMissing,
    882886            Annotationtype.PARTITION_DATE, Annotationtype.MULTIPLE_PIECES,
     
    886890            Annotationtype.DO_NOT_USE, Annotationtype.DO_NOT_USE_COMMENT,
    887891            Annotationtype.AUTO_PROCESSING
     892            ));
     893       
     894        jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.EXTRACTION_PROTOCOL, createIfMissing,
     895            Annotationtype.EXTERNAL_REF
    888896            ));
    889897       
     
    9991007
    10001008        jsonChecks.add(checkAnnotationTypeCategory(dc, Subtype.LIBRARY_PROTOCOL, createIfMissing,
    1001           Annotationtype.LIBPREP_TARGET
     1009          Annotationtype.LIBPREP_TARGET, Annotationtype.EXTERNAL_REF
    10021010          ));
    10031011
Note: See TracChangeset for help on using the changeset viewer.