Exemple #1
0
  @Override
  public IEntity getEntity(ORI collectionURI) {

    collectionURI = collectionURI.toAbsolute(query.getOn());

    Collection collection = store.getCollection(collectionURI);
    SqlEntity entity = new SqlEntity(collection);
    store
        .getSqlDialect()
        .loadEntity(
            query,
            store.getDDL(collectionURI),
            dataRS,
            entity,
            QueryUtils.newCollectionAlias(query, collectionURI));

    return entity;
  }
Exemple #2
0
  public Mutation(IEntity entity, ICollectionManager collectionManager, Parameters parameters) {
    super();

    // Parameters
    String fieldChr = parameters.get(ImpactDecoratorParameters.FIELD_CHR);
    String fieldPosition = parameters.get(ImpactDecoratorParameters.FIELD_POSITION);
    String fieldAllele = parameters.get(ImpactDecoratorParameters.FIELD_ALLELE);
    String fieldGeneid = parameters.get(ImpactDecoratorParameters.FIELD_GENEID);
    String fieldImpact = parameters.get(ImpactDecoratorParameters.FIELD_IMPACT);

    // Load mutation values
    this.collectionUri = entity.getCollection().getORI();

    Object value = entity.get(fieldChr);
    if (value != null) {
      this.chromosome = String.valueOf(value);
    }

    if ((value = entity.get(fieldPosition)) != null) {
      this.position = Long.valueOf(String.valueOf(value));
    }

    if ((value = entity.get(fieldAllele)) != null) {
      this.allele = String.valueOf(value);
    }

    this.impact = entity.get(fieldImpact);

    project = new ORI(collectionUri.getProjectUrl(), null);
    genesCollection = new ORI(parameters.get(ImpactDecoratorParameters.COLLECTION_GENES));
    ctCollection =
        new ORI(
            collectionUri.getProjectUrl(), parameters.get(ImpactDecoratorParameters.COLLECTION_CT));

    if ((value = entity.get(fieldGeneid)) != null) {
      this.ensembl = String.valueOf(value);

      IEntity gene = new EntityModel(genesCollection, this.ensembl).getObject();
      Object symbol = gene.get("SYMBOL");
      this.symbol = (symbol == null ? "" : "(" + String.valueOf(symbol) + ")");
    }

    // TODO Load mutation extra query
    this.externalId = "";
    this.recurrence = 0;
    this.samples = 0;
    this.frequency = 0.0;

    // Load mutation consequences
    this.consequences = new HashMap<String, Set<Consequence>>();

    String fromAlias = "c";
    Query query = new Query();
    query.setOn(project);
    query.addDefine(fromAlias, ctCollection);
    query.setFrom(fromAlias);
    query.addSelect(fromAlias, null);

    if (getPosition() != null) {
      query.setWhere(
          new And(
              new Equal(fromAlias, fieldChr, getChromosome()),
              new And(
                  new Equal(fromAlias, fieldPosition, getPosition()),
                  new And(
                      new Equal(fromAlias, fieldAllele, getAllele()),
                      new Equal(fromAlias, fieldGeneid, ensembl)))));
    } else {
      String cellLine = String.valueOf(entity.get("CELLLINEID"));
      String cancerSite = String.valueOf(entity.get("PROJECTID"));
      query.setWhere(
          new And(
              new Equal(fromAlias, "PROJECTID", cancerSite),
              new And(
                  new Equal(fromAlias, fieldGeneid, ensembl),
                  new Equal(fromAlias, "SAMPLEID", cellLine))));
    }

    IEntityTable ctTable = collectionManager.load(query);
    while (ctTable.next()) {
      Consequence ct = new Consequence(ctCollection, ctTable);
      if (!consequences.containsKey(ct.getSnv())) {
        consequences.put(ct.getSnv(), new HashSet<Consequence>());
      }
      consequences.get(ct.getSnv()).add(ct);
    }
  }