org.geneweaver.domain.Variant Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gweaver-stream-io Show documentation
Show all versions of gweaver-stream-io Show documentation
The IO bundle for Geneweaver.
/*-
*
* Copyright 2018, 2020 The Jackson Laboratory Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @author Matthew Gerring
*/
package org.geneweaver.domain;
import java.util.Collection;
import java.util.Collections;
import java.util.Objects;
import java.util.Set;
import javax.annotation.processing.Generated;
import org.neo4j.ogm.annotation.Index;
import org.neo4j.ogm.annotation.NodeEntity;
import com.fasterxml.jackson.annotation.JsonInclude;
/**
* The Class Variant.
*/
@Generated("POJO")
@NodeEntity(label="Variant")
public class Variant extends GeneticEntity {
/** The rs id. */
@Index(unique=true)
@JsonInclude(JsonInclude.Include.NON_NULL)
private String rsId;
/** The dbx ref. */
@JsonInclude(JsonInclude.Include.NON_NULL)
private String dbxRef;
/** The id. */
@JsonInclude(JsonInclude.Include.NON_NULL)
private String id; // Only id + species is unique, id number repeats.
/** The ref allele. */
@JsonInclude(JsonInclude.Include.NON_NULL)
private String refAllele;
/** The alt allele. */
@JsonInclude(JsonInclude.Include.NON_NULL)
private String altAllele;
/** The alt allele freq. */
@JsonInclude(JsonInclude.Include.NON_NULL)
private Float altAlleleFreq = 0F;
/** The biotype. */
@JsonInclude(JsonInclude.Include.NON_NULL)
private String biotype;
/** The variant effect. */
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Set variantEffect;
/**
* Gets the header.
*
* @return the header
*/
@Override
public String getHeader() {
StringBuilder buf = new StringBuilder();
buf.append("rsId:ID(Rs-Id)");
buf.append(getDelimiter());
buf.append("dbxRef");
buf.append(getDelimiter());
buf.append("id");
buf.append(getDelimiter());
buf.append("refAllele");
buf.append(getDelimiter());
buf.append("altAllele");
buf.append(getDelimiter());
buf.append("altAlleleFreq:float");
buf.append(getDelimiter());
buf.append("biotype");
buf.append(getDelimiter());
buf.append(super.getHeader());
return buf.toString();
}
/**
* To csv.
*
* @return the string
*/
@Override
public String toCsv() {
StringBuilder buf = new StringBuilder();
buf.append(getRsId());
buf.append(getDelimiter());
buf.append(getDbxRef());
buf.append(getDelimiter());
buf.append(getId());
buf.append(getDelimiter());
buf.append(getRefAllele());
buf.append(getDelimiter());
buf.append(getAltAllele());
buf.append(getDelimiter());
buf.append(getAltAlleleFreq());
buf.append(getDelimiter());
buf.append(getBiotype());
buf.append(getDelimiter());
buf.append(super.toCsv());
return buf.toString();
}
// Autogenerated
/**
* Gets the rs id.
*
* @return the rs_id
*/
public String getRsId() {
return rsId;
}
/**
* Sets the rs id.
*
* @param rs_id the rs_id to set
*/
public void setRsId(String rs_id) {
this.rsId = rs_id;
}
/**
* Gets the ref allele.
*
* @return the ref_allele
*/
public String getRefAllele() {
return refAllele;
}
/**
* Sets the ref allele.
*
* @param ref_allele the ref_allele to set
*/
public void setRefAllele(String ref_allele) {
this.refAllele = ref_allele;
}
/**
* Gets the alt allele.
*
* @return the alt_allele
*/
public String getAltAllele() {
return altAllele;
}
/**
* Sets the alt allele.
*
* @param alt_allele the alt_allele to set
*/
public void setAltAllele(String alt_allele) {
this.altAllele = alt_allele;
}
/**
* Gets the alt allele freq.
*
* @return the alt_allele_freq
*/
public Float getAltAlleleFreq() {
return altAlleleFreq;
}
/**
* Sets the alt allele freq.
*
* @param alt_allele_freq the alt_allele_freq to set
*/
public void setAltAlleleFreq(Float alt_allele_freq) {
this.altAlleleFreq = alt_allele_freq;
}
/**
* Gets the biotype.
*
* @return the biotype
*/
public String getBiotype() {
return biotype;
}
/**
* Sets the biotype.
*
* @param biotype the biotype to set
*/
public void setBiotype(String biotype) {
this.biotype = biotype;
}
/**
* Gets the id.
*
* @return the id
*/
public String getId() {
return id;
}
/**
* Sets the id.
*
* @param id the id to set
*/
public void setId(String id) {
this.id = id;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result
+ Objects.hash(altAllele, altAlleleFreq, biotype, dbxRef, id, refAllele, rsId, variantEffect);
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (!(obj instanceof Variant))
return false;
Variant other = (Variant) obj;
return Objects.equals(altAllele, other.altAllele) && Objects.equals(altAlleleFreq, other.altAlleleFreq)
&& Objects.equals(biotype, other.biotype) && Objects.equals(dbxRef, other.dbxRef)
&& Objects.equals(id, other.id) && Objects.equals(refAllele, other.refAllele)
&& Objects.equals(rsId, other.rsId)
&& equalsNullEmpty(variantEffect, other.variantEffect);
}
private boolean equalsNullEmpty(Collection> c1, Collection> c2) {
if (c1==c2) return true;
if (c1==null && c2 == null) return true;
if (c1==null && c2.isEmpty()) return true;
if (c1.isEmpty() && c2 == null) return true;
return Objects.equals(c1, c2);
}
/**
* Gets the variant effect.
*
* @return the variantEffect
*/
public Set getVariantEffect() {
if (variantEffect == null) return Collections.emptySet();
return variantEffect;
}
/**
* Sets the variant effect.
*
* @param variantEffect the variantEffect to set
*/
public void setVariantEffect(Set variantEffect) {
this.variantEffect = variantEffect;
}
/**
* Clear effects.
*/
public void clearEffects() {
if (getVariantEffect()!=null) getVariantEffect().clear();
}
/**
* Gets the dbx ref.
*
* @return the dbxRef
*/
public String getDbxRef() {
return dbxRef;
}
/**
* Sets the dbx ref.
*
* @param dbxRef the dbxRef to set
*/
public void setDbxRef(String dbxRef) {
this.dbxRef = dbxRef;
}
// Auto-generated stuff:
@Override
public String id() {
return getRsId();
}
@Override
public String toString() {
return "Variant [rsId=" + rsId + " start="+getStart()+" end="+getEnd()+" ]";
}
}