Changeset 5136


Ignore:
Timestamp:
Nov 22, 2018, 7:47:04 AM (5 months ago)
Author:
Nicklas Nordborg
Message:

References #1081: The release exporter should export more data

Added NoSpecimenWriter implementation. Annotations:

  • Site
  • SamplingDate
  • Laterality


The !NameToExternalID mapping has also been updated to allow more item types than specimen. It may not actually be needed for NoSpecimen items that doesn't have any child items.

Location:
extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/dao/NoSpecimen.java

    r4964 r5136  
    191191  }
    192192
     193  /**
     194    Get the parent case.
     195    @since 4.21
     196  */
     197  public Case getCase()
     198  {
     199    Sample noSpecimen = getItem();
     200    Sample theCase = (Sample)noSpecimen.getParent();
     201    return Case.get(theCase);
     202  }
    193203
    194204}
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/CohortItem.java

    r5132 r5136  
    2020import net.sf.basedb.core.AnyToAny;
    2121import net.sf.basedb.core.BasicItem;
     22import net.sf.basedb.core.BioMaterial;
    2223import net.sf.basedb.core.BioSource;
    2324import net.sf.basedb.core.DbControl;
     
    5051import net.sf.basedb.reggie.dao.MaskedSequences;
    5152import net.sf.basedb.reggie.dao.MergedSequences;
     53import net.sf.basedb.reggie.dao.NoSpecimen;
    5254import net.sf.basedb.reggie.dao.Patient;
    5355import net.sf.basedb.reggie.dao.PooledLibrary;
     
    8890  private List<Case> cases;
    8991  private List<SpecimenTube> specimens;
     92  private List<NoSpecimen> noSpecimens;
    9093  private List<Lysate> lysates;
    9194  private List<Rna> rna;
     
    100103  private List<Rawbioassay> cufflinksBioAssays;
    101104 
    102   private ValueConverter<String, String> NAME_TO_EXTERNAL_ID;
    103   private ValueConverter<String, String> DATA_FILES_FOLDER_TO_RELEASE_FOLDER;
     105  private final NameToExternalIdConverter NAME_TO_EXTERNAL_ID;
     106  private final DataFilesFolderToRelaseFolderConverter DATA_FILES_FOLDER_TO_RELEASE_FOLDER;
    104107  private final NameToParentDerivedBioAssayConverter TO_PARENT_BIOASSAY_CONVERTER;
    105108 
     
    117120    this.patient = Patient.getById(dc, biosource.getId());
    118121    this.TO_PARENT_BIOASSAY_CONVERTER = new NameToParentDerivedBioAssayConverter();
     122    this.NAME_TO_EXTERNAL_ID = new NameToExternalIdConverter();
     123    this.DATA_FILES_FOLDER_TO_RELEASE_FOLDER = new DataFilesFolderToRelaseFolderConverter(NAME_TO_EXTERNAL_ID);
    119124  }
    120125 
     
    260265      ItemQuery<Sample> query = queryManager.getSpecimenQuery(getCases());
    261266      specimens = query == null ? Collections.emptyList() : SpecimenTube.toList(query.list(dc));
    262       NAME_TO_EXTERNAL_ID = new NameToExternalIdConverter(specimens);
    263       DATA_FILES_FOLDER_TO_RELEASE_FOLDER = new DataFilesFolderToRelaseFolderConverter(NAME_TO_EXTERNAL_ID);
     267      NAME_TO_EXTERNAL_ID.map(specimens);
    264268    }
    265269    return specimens;
    266270  }
    267271
     272  /**
     273    Get all specimen that belong to this patient and have a valid Case.
     274    The specimen items must have DoNotUse=null.
     275    @since 4.21
     276  */
     277  public List<NoSpecimen> getNoSpecimens()
     278  {
     279    if (noSpecimens == null)
     280    {
     281      ItemQuery<Sample> query = queryManager.getNoSpecimenQuery(getCases());
     282      noSpecimens = query == null ? Collections.emptyList() : NoSpecimen.toList(query.list(dc));
     283      NAME_TO_EXTERNAL_ID.map(noSpecimens);
     284    }
     285    return noSpecimens;
     286  }
     287
     288 
    268289  /**
    269290    Get all lysate items that belong to this patient and have a valid Specimen.
     
    659680    private final Pattern specimenNamePattern;
    660681    private final Map<String, String> nameToExternalId;
    661     NameToExternalIdConverter(List<SpecimenTube> specimen)
     682    NameToExternalIdConverter()
    662683    {
    663684      this.specimenNamePattern = Pattern.compile("(\\d{7}\\.\\d+)(.*)");
    664685      this.nameToExternalId = new HashMap<>();
    665       for (SpecimenTube sp : specimen)
     686    }
     687   
     688    void map(List<? extends ReggieItem<? extends BioMaterial>> items)
     689    {
     690      for (ReggieItem<? extends BioMaterial> item : items)
    666691      {
    667         nameToExternalId.put(sp.getName(), sp.getItem().getExternalId());
     692        nameToExternalId.put(item.getName(), item.getItem().getExternalId());
    668693      }
    669694    }
     
    677702        String spName = m.group(1);
    678703        String externalId = nameToExternalId.get(spName);
     704        if (externalId == null)
     705        {
     706          throw new InvalidDataException("Could not find release ID for: " + spName);
     707        }
    679708        return externalId + m.group(2);
    680709      }
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/QueryManager.java

    r5131 r5136  
    5151  private ItemQuery<Sample> caseQuery;
    5252  private ItemQuery<Sample> specimenQuery;
     53  private ItemQuery<Sample> noSpecimenQuery;
    5354  private ItemQuery<Sample> histologyQuery;
    5455  private ItemQuery<Sample> goodStainQuery;
     
    112113 
    113114  /**
     115    Get a query that is returning all NoSpecimen items that are related
     116    to the given list of cases. The query is filtered to only return
     117    items with DoNotUse=null.
     118    @return A query or null if the list is null or empty
     119  */
     120  public ItemQuery<Sample> getNoSpecimenQuery(List<Case> cases)
     121  {
     122    if (cases == null || cases.isEmpty()) return null;
     123    if (noSpecimenQuery == null)
     124    {
     125      noSpecimenQuery = Sample.getQuery();
     126      initBioMaterialQuery(noSpecimenQuery, Subtype.NO_SPECIMEN, Subtype.CASE, ParentRestriction.LIST_ID);
     127      annotationEquals(noSpecimenQuery, Annotationtype.DO_NOT_USE, null);
     128    }
     129    noSpecimenQuery.setParameter("parents", idList(cases), Type.INT);
     130    return noSpecimenQuery;
     131  }
     132
     133  /**
    114134    Get a query that is returning the Histology item that is related
    115135    to the given specimen. The query is filtered to only return
  • extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/plugins/release/ReleaseExporter.java

    r5131 r5136  
    165165      jsonWriter.registerItemWriter(new IncaWriter(dc, options));
    166166      jsonWriter.registerItemWriter(new SpecimenWriter(dc, options, outputLocation, scriptWriter));
     167      jsonWriter.registerItemWriter(new NoSpecimenWriter(dc, options));
    167168      jsonWriter.registerItemWriter(new LysateWriter(dc, options));
    168169      jsonWriter.registerItemWriter(new RnaWriter(dc, options));
Note: See TracChangeset for help on using the changeset viewer.