All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.geneweaver.io.connector.TranscriptOverlapConnector Maven / Gradle / Ivy

package org.geneweaver.io.connector;

import org.geneweaver.domain.AbstractEntity;
import org.geneweaver.domain.Entity;
import org.geneweaver.domain.Located;
import org.geneweaver.domain.Transcript;
import org.geneweaver.domain.TranscriptOverlap;
import org.geneweaver.domain.Variant;

/**
 * Used for the overlaps between Variant and Transcript
 * 
 * @author gerrim
 *
 */
public class TranscriptOverlapConnector extends AbstractOverlapConnector {

	public TranscriptOverlapConnector() {
		this("transcripts");
	}

	/**
	 * Create an overlap connector setting the base file name. 
	 * The database is sharded by file so this
	 * @param databaseFileName
	 */
	public TranscriptOverlapConnector(String databaseFileName) {
		setTableName(System.getProperty("gweaver.mappingdb.tableName","REGIONS"));
		setFileName(databaseFileName);
		setFileFilters(".gtf.gz", ".gtf");
	}
		
	@Override
	protected Located createIntersectionObject(String id, int start, int end) {
		return new Transcript(id, start, end);
	}

	/**
	 * Implement to provide custom filtering to the input stream.
	 * @param loc
	 * @return
	 */
	@Override
	protected boolean filter(Located loc) {
		if (loc instanceof Transcript) {
			return true;
		}
		return false;
	}

	@Override
	public  T create(Located loc, Variant variant) {
		
		if (loc instanceof Transcript) {
			TranscriptOverlap ret = new TranscriptOverlap();
			ret.setTranscript(loc);
			ret.setVariant(variant);
			return (T) ret;
		}
		throw new IllegalArgumentException("Cannot intersect with "+loc);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy