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

net.maizegenetics.pangenome.db_loading.PHGData Maven / Gradle / Ivy

There is a newer version: 1.10
Show newest version
/**
 * 
 */
package net.maizegenetics.pangenome.db_loading;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;

import com.google.common.collect.Multimap;
import com.google.common.collect.Range;
import com.google.common.collect.RangeMap;

import net.maizegenetics.dna.map.Position;
import net.maizegenetics.pangenome.db_loading.DBLoadingUtils.AnchorType;
import net.maizegenetics.util.Tuple;

/**
 * @author lcj34
 *
 */
public interface PHGData {

    /**
     * Return genoid
     * @param line_name
     * @return
     */
    int getGenoidFromLine(String line_name);
    
    /**
     * Returns hapid for given line name and hap_number
     * @param genoid
     * @param hap_number
     * @return
     */
    int getHapidForGenoidHapNumber(int genoid, int hap_number);
    
    /**
     * Returns list of hapids for a given line name
     * @param genoid
     * @return
     */
    List getHapidsForGenoid(int genoid);

    /**
     * Method to retrieve both a line name and the hap number given a hapid.
     * @param hapid
     * @return  Tuple consisting of Tuple
     */
    Tuple getLineNameHapNumberFromHapid(int hapid);

    /**
     * Retrieves line name and hapnumber, and returns them with the hapid.
     * hapid is the key in the map.  THe line name and hap number are concatenated
     * with an underscore and returned as the string value for each hapid.
     * @param lineNames
     * @return
     */
    Map getHapidHapNumberLineNamesForLines(List lineNames);
   
    /**
     * Method grabs a list of distinct chromosome names for a genome_interval version
     * 
     * @param line_name
     * @param hap_number
     * @param version  Version name for anchors
     * @return
     */
    List getChromNamesForHaplotype(String line_name, int hap_number, String version);

    /**
     * Returns method_id given a method name. or 0 if no id found for the given name
     * @param method_name
     * @return
     */
    int getMethodIdFromName(String method_name);

    /**
     * Returns a map of  created from the genotypes
     * and haplotypes table.  
     * @return
     */
    Map getHapidMapFromLinenameHapNumber();

    /**
     * Takes a list of taxa and returns the corresponding gamete_group_id or 0
     * @param gametes Items on the list must be of the form taxon_hapNumber
     * @return
     */
    int getGameteGroupIDFromTaxaList(List gametes);

    /**
     * Returns reference range id
     * @param refData needs to be of form chr1:startpos:endPos
     *
     * @return
     */
    int getRefRangeIDFromString(String refData);

    /**
     * Returns the haplotype_id from the haplotypes table based on the gamete_grp_id
     * (calculated from the taxa list), the ref_range_id (calculated from the 
     * ref coordinates part of the idline) and the method.
     * 
     * @param idLine expected form:  refchr:refStartPos:refEndPos;taxa_hapnumber:taxa_hapnumber:etc
     * @param methodName This is the method used for creating the haplotypes
     * @return
     */
    int getHaplotypeIDFromFastaIDLine(String idLine, String methodName);

    /**
     * Returns sorted treeRangeMap of Positions for specified chromosome
     * @param chrom
     * @return
     */
    RangeMap getIntervalRangesWithIDForChrom( String chrom);
    

    /**
     * THis method pulls the haplotype_counts_id and corresponding path for all entries
     * in the paths table with the specified method.
     * @param method
     * @return Map of Haplotype_counts_id/paths
     */
    Map getHapCountsIDAndPathsForMethod(String method);
    
    /**
     * This method pulls the haplotype_counts_id with corresponding genotypes line name and data for all DB entries  
     * based on the supplied method
     * @param method
     * @return Map of  from haplotype_counts table
     */
    Map> getHapCountsIDAndDataForVersionMethod(String method);

    /**
     * Method uses line_name, method_name and file_Group_name to fetch a read_mapping_id.
     * -1 returned if the this combination is not present in the db.
     * @param line_name
     * @param method_name
     * @param file_group_name
     * @return  read_mapping_id or -1
     */
    int getReadMappingId(String line_name, String method_name, String file_group_name);

    /**
     * Method to get the Read Mapping data from the DB using the read_mapping_id.
     * Generally this is returned from PHGData.getReadMappingId(String line_name, String method_name, String file_group_name)
     * @param readMappingId
     * @return byte array of the read mapping data.
     */
    byte[] getReadMappingsForId(int readMappingId);

    /**
     * Method to get the mapping ids by method
     * @param methodName
     * @return
     */
    List getReadMappingsForMethod(String methodName);

    /**
     * Method to get a list of all genoid line_names that have paths for
     * method = method_name.
     * @param method_name
     * @return
     */
    Set getTaxaForPathMethod(String method_name);

    /**
     * Returns a map of taxon to paths for that taxon from the paths table
     * for a specified method name.
     *
     * @param method_name
     * @return
     */
    Map getTaxonPathsForMethod(String method_name);

    /**
     * Method to check to see if a given taxon and fileGroup are already in the readMapping table of the DB.
     * @param taxon
     * @param fileGroupName
     * @param methodName
     * @return
     */
    boolean isFileGroupNew(String taxon, String fileGroupName, String methodName);

    /**
     * Method queries the db methods table for the description field given a methods name
     * @param method_name:  name of method
     * @return Map of plugin parameter to value as stored for the DB.  Null if the method does not exist
     */
    Map getMethodDescriptionFromName(String method_name);

    /**
     * Method to return all reference ranges associated with a specified method name
     * @param methodName name of method group for which the user wants reference range ids
     * @return A list of reference_range_ids associated with the speciried mathod name.
     */
    List getRefRangesForMethod(String methodName);
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy