edu.mayo.bsi.ngsportal.server
Class NGSPortalServiceImpl

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
              extended by com.google.gwt.user.server.rpc.RemoteServiceServlet
                  extended by edu.mayo.bsi.ngsportal.server.NGSPortalServiceImpl
All Implemented Interfaces:
com.google.gwt.user.client.rpc.RemoteService, com.google.gwt.user.server.rpc.SerializationPolicyProvider, NGSPortalService, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class NGSPortalServiceImpl
extends com.google.gwt.user.server.rpc.RemoteServiceServlet
implements NGSPortalService

The server side implementation of the RPC service.

See Also:
Serialized Form

Field Summary
static String JVM_SYS_PROP_H2
          JVM system property that indicates whether the H2 database connection should be used instead of the MS SQL Server connection.
static String kAddSecondaryAnalysis
          Parameter that says we're doing Add the Secondary Analysis
static int kAlreadyExists
          Tried to add an item that is already in the DB
static String kAnalysisDate
          Date Analysis was done
static String kAnalysisName
          Name of the Analysis Project the AnalysisGroup belongs to
static String kAppNameQuery
          Application that did the Secondary Analysis
static int kAttachToGroup
          Specifies that the key : value pair is about a Group
static int kAttachToProject
          Specifies that the key : value pair is about a Project
static int kAttachToRun
          Specifies that the key : value pair is about a run
static int kAttachToSample
          Specifies that the key : value pair is about a sample
static int kAttachToSequencedSample
          Specifies that the key : value pair is about a sequenced sample
static int kAttachToUser
          Specifies that the key : value pair is about a user
static String kCompleteQuery
          Parameter to include if analysis is complete
static String kConnection
          URL Parameter for the connectionID to decode the password of the user
static String kFailedQuery
          Parameter to include if analysis failed
static int kFastQCellInfoCol
          The part of the FastQ or Flagstat file name that holds the flowcell information
static String kFastQSplitter
          String that divides the components of a FastQ File's name
static String kFlowCell
          Flow cell the run was run on
static String kFlowSplitter
          String that divides the flow cell information of a FastQ File's name
static String kGetUserRuns
          Query Parameter to tell the servlet to retrieve the runs accessible by a given user
static String kIndexQuery
          Index sequence for the sample, if any
static int kInvalidID
          An invalid DB ID
static String kJVMIsDev
          JVM system property that indicates whether using Dev DB, or Prod DB
static String kJVMIsTunneled
          JVM system property that indicates whether using a tunneled connection to the primary DB, or else connecting directly
static String kLanesQuery
          Lanes the analysis was run on, none for all lanes
static int kNumNegReturnCodes
          Count of failure codes
static String kPassword
          URL Parameter for the password of the user who will own this run
static String kPasswordParam
          On encoded byte of the password per parameter
static String kQCDataFile
          The file that contains the QC information
static String kQCRunInformation
          Information about the QC Run
static String kReAnalysisType
          Project Type for a ReAnalysis Project
static String kRunName
          The RLIMS name for the run
static String kRunQuery
          Name of the run the analysis was done on
static String kSampleName
          The Sample Name
static int kServletVersion
          Version given to callers of the servlet Web Page, as opposed to the GWT web page
static String kStatusQuery
          Status of the analysis
static String kUploadData
          Query Parameter to tell the servlet to load one or more data files
static String kUserName
          URL Parameter for the lan id of the user who will own this run
static String kUserParam
          Database user name
static String[] kValidCopyRoles
          Roles that can be granted to a user via copyUserPermissions ()
static String kVersion
          Version of the analysis
static String kWriteDir
          Where the upload servlets save data files
 
Fields inherited from interface edu.mayo.bsi.ngsportal.shared.NGSPortalService
kFirstLabUserRole, kLastLabUserRole, kRoleAdmin, kRoleCoPI, kRoleInformaticsLead, kRoleInformaticsPhdLead, kRoleInformaticsSpecialist, kRoleIt, kRoleLabManager, kRoleLabTech, kRolePI, kRoleProjCreator, kRoleProjLead, kRoleProjPI, kRoleProjSpec, kRoleResearcher, kRoleSpa, kRoleStatistician
 
Constructor Summary
NGSPortalServiceImpl()
          Default constructor.
NGSPortalServiceImpl(Authenticator authenticator, edu.mayo.commons.dir.PersonFinder personFinder)
          Constructor
 
Method Summary
 boolean addExternalUser(String firstName, String lastName, String id)
          Add an external user to the database
 int addGroup(int connectionID, String name, String description)
          Adds a new group
 boolean addKeyValuePair(int connectionID, int table, String name, String more, String key, String value)
          Add a Key : Value pair about a specified item to the DB
 boolean addLocationInformation(String[] pis, String[] runs, String[] flowCells, int[] lanes, String[] indexes, String[] locations, String[] sizes, String user, String password)
          Add location information to the Sequenced Sample table
 boolean addMetadata(String[] pis, String[] runs, String[] flowCells, String[] sampleNames, String[] familyIDs, String[] parentIDs, String[] rlimsIDs, int[] lanes, String[] indexes, String[] readTypes, String[] apps, int[] cycles, String user, String password)
          Add metadata to the DB.
 String addNewRerun(int connectID, int projectID, String projectName)
           
 boolean addNote(int connectionID, String note, String tableName, int rowID)
          Adds a note to the database
 String addProject(int connectionID, String notes, boolean isReanalysis, int[] seqSampleIDs, Integer leadID, Integer specID, Integer piID)
          Adds a new project.
 boolean addRLIMSBatchIDs(String user, String password)
          Gets the runs that don't have RLIMS Batch IDs, and looks for the IDs, adding them if they exist
 boolean addSampleAnalysis(int connectionID, int groupID, String appName, double version, String status, Date analysisDate, boolean complete, boolean failed)
          Add a Secondary analysis to the DB, setting up all the relevant information
 boolean addSampleAnalysis(String projectName, String appName, double version, String status, Date analysisDate, String user, String password, boolean complete, boolean failed)
          Add a Secondary analysis to the DB, setting up all the relevant information
 boolean addSecAnLinks(int[][] mappings)
          Add these sequenced samples and Secondary Analysis to the Secondary Analysis linker table
 boolean addToFamily(int connectionID, String family, String parentID, String rlimsID, String sampleParentID, String name, Boolean isMale)
          Add a sample to a family, creating the family if necessary.
 boolean addUsersToGroup(int connectionID, int groupID, Map<String,Integer> users)
          Add users to an existing group
 boolean addUsersToProject(int connectionID, Map<String,Boolean> users, int role, String project)
          Give one or more users' access to a project
 int assignAnalysisGroups(String user, String password)
          Iterate over the AnalysisGroup table, looking for AnalysisGroups that are not assigned to a Secondary Project, but have the same sequenced samples as an existing Secondary Project, and assign the AnalysisGroup to the SecondaryProject
 boolean checkAccessPrivilages(String userID)
          Checks the user access
 String checkIfProjectNameIsUnique(String projectName, Connection theConnection)
          Checks if the Project Name entered by Admin already exists
 boolean compareToRLIMS(String user, String password)
          Parses the entire RLIMS system, checking to find those runs where we don't have as many samples for a run as RLIMS does
 String copyUserPermissions(String sourceUser, String sourceUserRole, String[] targetUsers, String targetUserRole, String sourceRun, String sourceFlowcell, int sourceLane, String sourceIndex, String targetRun, String targetFlowcell, int targetLane, String targetIndex, String user, String password)
          Copies user permissions (i.e.
 int createAnalysisGroup(int connectionID, String analysisName, String runName, String flowCell, String index, int[] lanes)
          Add an Analysis Group to the DB, setting up all the relevant information
 int createAnalysisGroup(String analysisName, String runName, String flowCell, String index, int[] lanes, String user, String password)
          Add an Analysis Group to the DB, setting up all the relevant information
 boolean deleteGroup(int connectionID, int groupID)
          Delete an existing group, and all related information
 boolean deleteNote(int connectionID, String tableName, int rowID, Date noteDate)
          Deletes a note from the database.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Routine to produce the text displayed by this servlet when it is directly accessed by a web browser.
 int findOverlappingSecondaryProjects(String user, String password)
          Iterate over the SecondaryProjectInformation table, looking for SecondaryProjects that do not have an Analysis group with a Beginning and Delivered Status.
 Set<String> findUnmatchedRuns(String[] testPaths)
          Find any runs in the DB that have samples with Flagstat data, where there isn't a run folder with Flagstat files in any of the testPaths
static String formatDate(Date theDate)
          Format a date in the format that the servlet wishes to receive dates
 Map<String,Integer> getAllSecondaryStatuses()
          Get the Secondary Analysis Statuses and their DB row IDs
 List<String> getAnalysisDates(Date startDate, Date endDate, String application, String[] runNames, String pi, boolean tabDelim, String user, String password)
          Get a List of Strings, each one holding
Run Name Application Investigator CIM BIC Primary Delivered Secondary Complete Secondary Delivered
delimited with either a tab or a comma
 List<String> getAnalysisStatuses()
          Get the names for each of the analysis statuses the database recognizes
 List<String> getAnalysisTypes()
          Get the names for each of the analysis types the database recognizes
 List<AnalysisInfo> getAnalyzedSamples(int connectionID, String theRun)
          Finds all the samples for a run that have had an analysis done
 List<String> getApplicationTypes()
          Get the Descriptions for each of the application types the database recognizes
 List<String> getApplicationTypes(String runID, String pi)
          Get the Descriptions for each of the application types the database recognizes, that occur with the specified PI and / or runID
 int getApplicationTypesForSamples(int[] sampleIDs)
          Gets the ID of the Application Type for more of the passed in samples than anyone else
 List<SGEScriptSummary> getAvgCPUSecondsPerScript(SGEFilter filter, int connectionID)
          Queries the portal database and returns a list of SGEScriptSummary containing the average of cpuseconds consumed by the scripts defined by the provided SGEFilter
 List<SGEScriptSummary> getAvgRun(SGEFilter filter, int connectionID)
          Queries the portal database and returns a list of SGEScriptSummary containing the sum of cpuseconds consumed by the scripts defined by the provided SGEFilter
 List<RunData> getCompletedRuns(int connectionID, String piName, String runID)
          Get all the completed runs
 ConnectionResponse getConnection()
          Give the client the information it needs in order to send data to the server
 List<ContactInfo> getContacts(int connectionID, int[] contactIDs)
          Gets one or more contacts.
 Map<String,PrimaryAnalysisBean> getCurrentPrimaryStatus(int connectionID)
          Get the latest primary analysis statuses, from all the primary analysis results that have been updated in the last week
 String getDefaultProjectName(String runName, String appType, String pi, boolean isReanalysis)
          Get a default Secondary Project Reanalysis name from the server given the run, PI, and appType, then ask the user for the reanalysis name, given the default name
 Map<String,Integer> getErrorsPerRun(SGEFilter filter, int connectionID)
          Returns a set of pairs of RunIDs - ScriptNames and error counts defined by the passed filter object.
 List<FileLocation> getFileLocations()
          Get a List of the available FileLocations that files might be saved in
static String getFlowCell(String[] split)
          Get the flowCell from the split up components of the FastQ File name
 Map<String,Integer> getFlowcellsPerMonth(SGEFilter filter, int connectID)
           
 List<GroupInfo> getGroups(int connectionID)
          Get the list of all the groups in the DB
static String getIndex(String[] split)
          Get the index from the split up components of the FastQ File name
 List<InstrumentInfo> getInstrumentHistory(int connectionID, String instrument)
          Get all the actions recorded for the given instrument
 Map<String,String> getInstrumentStatus(int connectionID)
          Query the Primary Analysis DB for the runs that have completed the given task, and when they did it
 Map<String,String> getISdetails()
          Get a map from LAN IDs to names for all the Informatics Specialists
static int getLane(String[] split)
          Get the lane from the split up components of the FastQ File name
 List<ResultInfo> getMatchingRuns(int connectionID, String piName, String runID, String sample, String application, String rlimsProject, String rlimsID, Date startDate, Date endDate, boolean onlyAnalyzed, String projName)
          Search the database for all the runs matching the criteria given, and return them
 List<Note> getNote(int connectionID, String tableName, int rowID)
          Get one or more notes from the database
 int getPIForSamples(int[] sampleIDs)
          Gets the ContactLinker ID of the Contact who is the PI for more of the passed in samples than anyone else
 List<String> getPINames()
          Get the names of all the PIs in the database
 List<String> getPrimaryAnalysisStatuses()
          Get the names for each of the Primary Analysis Statuses the database recognizes
 List<String> getPrimaryProjectNames(int connectionID)
          Get the names of all the projects in the database
 List<String> getProjectNames(int connectionID)
          Get the names of all the secondary analysis projects in the database that this user can see
 List<ProjectInfo> getProjects(int connectionID, int[] projIDs)
          Gets one or more projects.
 List<SecondaryProjectInfo> getProjects(int connectionID, String projectName)
          Get all the Secondary Projects created by this individual, or the single project projectName
 ProjectSummaryBuilder getProjectsSummary(int connectionID, String userLanID, Date fromDate, Date toDate)
           
 List<QCResult> getQCResults(int connectionID, String sampleName, String runID)
          Get all the information about the QCResults for a sample from a given run
static int getRead(String[] split)
          A1-Input_hMeDIP.FCC3PBEACXX_L7_IACAGTG.flagstat fastqc/A1-Input_hMeDIP.FCC3PBEACXX_L7_R1_IACAGTG_fastqc/fastqc_data.txt* Get the read from the split up components of the FastQ File name
 List<String> getReadTypes()
          Get the Descriptions for each of the read types the database recognizes
 int getReanalysisProjects(String user, String password)
          Get all the secondary projects that don't have an analysis group pointing to them, and that share a set of samples with secondary projects that also don't have an analysis group pointing to them
 List<ReportData> getReport(int connectionID, String piName, String instrument, int appType, Date minStartDate, Date maxStartDate, Date minEndDate, Date maxEndDate)
          Get a report on the runs specified by the following criteria
 List<ResultInfo> getRetainedSamples(int connectionID, String piName, String runID, String sample, boolean isPrimary)
          Get all the runs and samples that have data files that are currently marked for non-deletion
 List<String> getRLIMSIDs(int connectionID)
          Get all the RLIMS Sample "Sample IDs" in the database that this user can see
 List<String> getRLIMSProjectNames(int connectionID)
          Get all the RLIMS project names in the database that this user can see
 List<String> getRoles()
          Get all the Contact Roles in the database
 RunData getRunData(int connectionID, String piName, String runID)
          Get all the metadata from a given run, owned by a given PI
 List<String> getRunIDs(int connectionID)
          Get all the run IDs in the database this user can see
 List<String> getRunIDs(int connectionID, String pi, String appType)
          Get all the run IDs in the database this user can see, that have at least one sample that has the specified PI and / or application type
 boolean getRunSecondaryAnalysisStatus(List<Integer> sampleIDs)
          Runs a SQL query to find if any of the Sequenced Samples in sampleIDs have a Secondary Analysis result of Delivered
 List<SampleData> getRunsSamples(String[] runIDs, String appType, String pi, String[] sampleNames, String[] sampleRLIMSIds, String[] sampleFamilyIds, String[] sampleParentIds, String[] rlimsProjectNames, Date startDate, Date endDate, int minNumReads, String user, String password)
          Get all the information about all the samples from a given run, owned by a given PI
 List<String> getSampleNames(int connectionID)
          Get the names of all the samples in the DB
 List<SampleInfo> getSampleNames(int connectionID, String piName, String runID)
          Get all the information about all the samples from a given run, owned by a given PI
 List<SampleInfo> getSamples(int connectionID, String piName, String runID, String appType, String projectName)
          Get all the information about all the samples from a given run, owned by a given PI
 Map<String,Integer> getSamplesPerMonth(SGEFilter filter, int connectionID)
          Returns a set of pairs of months and unique samples defined by the passed filter object.
 List<SGEScriptSummary> getScriptInvocations(SGEFilter filter, int connectionID)
          Queries the portal database and returns a list of SGEScriptSummary containing the total script invocations in the runs defined by the provided SGEFilter
 List<SecondaryDetails> getSecondaryAnalysisHistory(int connectid, int projectid)
           
 List<Analysis2> getSecondaryAnalysisResults(int connectionID, Date finishedCutoff)
          Get all the information about the Secondary Analysis results for a sample from a given run
 Map<String,List<SecondaryAnalysisBean>> getSecondaryStatus(int connectID)
          SQL query and result set to Return current Secondary Analysis status
 Map<String,Integer> getSGEFlowcellsPerMonth(SGEFilter filter, int connectionID)
           
 List<SGEScriptSummary> getSumCPUSecondsPerScript(SGEFilter filter, int connectionID)
          Queries the portal database and returns a list of SGEScriptSummary containing the sum of cpuseconds consumed by the scripts defined by the provided SGEFilter
 List<String> getValidRLIMS(SGEFilter filter, int connectionID)
          Queries the portal database and returns a list of possible RunIDs falling within the provided SGEFilter
 List<String> getValidRunTypes(int connectionID)
          Returns a list of possible Run Types (eg., exome, whole_genome,...) available
 Map<String,Double> getWallClockPerRun(SGEFilter filter, int connectionID)
          Returns a set of pairs of WallClock times and RunIDs defined by the passed filter object.
 Map<String,Double> getWallClockPerSample(SGEFilter filter, int connectionID)
          Returns a set of pairs of WallClock times and SampleIDs defined by the passed filter object.
 boolean grantProjectAccess(int connectionID, String project, String run, List<String> samples)
          Routine to add samples to a project
 boolean grantUserAccess(int connectionID, Map<String,Boolean> users, int role, String run, List<String> samples)
          Routine to give users access to samples that the caller has access to
 void init()
          Initialize settings from the properties file, then setup the connections pool for the default user id.
static boolean isEmpty(String tested)
          Utility routine for the common String test
static boolean isTesting()
           
 int joinAnalysisGroups(String user, String password)
          Iterate over the AnalysisGroup table, consolidating AnalysisGroups that are from the same run and PI, and have the same appType, so long as their start and end are within a couple of days of each other
 ConnectionResponse logIn(String lanID, String password, int connectID)
          Tell the server the lanID and Password (encrypted) of the person doing the querying, and get told by the server if the lan ID and password are valid
 void logOut(String userName, String password, int connectID)
          Tell the server to forget about this user, and the user's current connection
static String makeSQLSafe(String tested)
          Utility routine for the common String test
 int moveSecAnToAnalysisGroups(String user, String password)
          Iterate over the SecondaryAnalysisLinker table, adding all the secondary analyses there to the AnalysisGroup table
 int nameSecondaryProjects(String user, String password)
          Iterate over the SecondaryProjectInformation table, looking for SecondaryProjects that do not have a name and do have samples, and give them one based upon the run, appType, and PI associated with their samples
 boolean parseQCFolder(String folderPath, String[] runNames, String user, String password)
          Parses the passed in file.
 boolean parseQCFolder(String folderPath, String user, String password)
          Parses the passed in directory, parses all the fastqc_data.txt files in that directory, or in any of its sub-directories.
 boolean parseRLIMS(String user, String password)
          Parses the entire RLIMS system.
 boolean parseRLIMSRun(String[] runNames, String user, String password)
          Gets the data about a list of runs from RLIMS, and adds any new runs or samples to the DB
 boolean parseRunFile(String filePath, String user, String password)
          Parses the passed in file.
 boolean removeFromFamily(int connectionID, String family, String rlimsID, String parentID)
          Remove a sample from a family
 void removeProject(int connectionID, int projID)
          Code to delete a Patrick style Project
 void removeProject(int connectionID, String projectName)
          Removes an existing project.
 boolean removeUsersFromGroup(int connectionID, int groupID, List<String> users)
          Remove users from a group
 boolean removeUsersFromProject(int connectionID, List<String> users, String project)
          Routine to remove one or more users' access to a project
 boolean retainSample(int connectionID, Date deleteDate, String piName, List<String> runIDs, String sample, String requestor, boolean isPrimary)
          Mark a sample or set of samples as needing their data files to be retained
 boolean revokeProjectAccess(int connectionID, String project, String run, List<String> samples)
          Routine to remove samples from a project
 boolean revokeUserAccess(int connectionID, List<String> users, String run, List<String> samples)
          Routine to remove users' access to samples that the caller has PI access to, or where the caller has all sample access.
 void saveBatched(int connectID, int projectID, String value)
          Saves the batched value
 void saveNotes(int connectID, int projectID, String runName, String pI, String application, String personnel, String newNotes)
          Save Notes to the Database.
 void savePersonneltoDB(int connectID, int projectID, String newISAssignee, String oldISAssignee)
           
 void saveSecondaryAnalysisNotes(int connectID, int analysisID, String notes)
          Replace the notes for a secondary analysis.
 void saveSecondaryAssignedDate(int connectID, int projectID, Date newValue)
           
 void saveSecondaryCompleteDate(int connectID, int projectID, Date date)
          Saves the secondary Complete Date.
 void saveSecondaryDeliveryDate(int connectID, int projectID, Date date)
          Saves the Secondary Delivery Date
 void saveSecondaryStartDate(int connectID, int projectID, Date date)
          Saves the Secondary Start Date
 void sendEmailNotification(int connectID, String runName, String application, String pi, String assignerLanID, String notes, String newAssignee, String oldAssignee, int projectID)
          Saves the Assigned Date and Personnel to the DB
 boolean sendWeeklyReport(String userlanID, int connectionID)
          Generate an EMail Weekly Report
 boolean setIsBIC(int connectionID, boolean isBIC, int projectID)
          Sets all the samples for a project to have their isBIC field either be true or false
 boolean setRunData(int connectionID, String piName, String runID, RunData theRun, List<SampleInfo> samples, int[] deletedIDs)
          Update all the metadata for a given run, owned by a given PI
 Map<String,List<SecondaryAnalysisBean>> sqlresultToSecondaryAnalysis(ResultSet rs)
          Converts Secondary Analysis Result set to SecondaryAnalysisBean
 String testSecondaryProjectMembership(String projectName, String runName, String flowCell, String index, int[] lanes, String user, String password)
          Verify that the specified samples are all in the specified project
 boolean updateAnalysis(String analysisPath, String uID, String password)
          Update the database with all the new analyses that have been added
 boolean updateGroup(int connectionID, int groupID, String name, String description)
          Updates information about an existing group
 void updateProject(int connectionID, String projectName, String notes, boolean isReanalysis, int[] seqSampleIDs, Integer leadID, Integer specID, Integer piID)
          Updates an existing project.
 boolean updateRunDates(String user, String password)
          Query the Primary Analysis database for information about run primary analysis dates
 boolean updateSampleIDInfo(String user, String password)
          Query the Dev DB for Sample ID and Ultimate Parent ID information for existing production Sequenced Samples, and update the production Sequenced Samples and their samples
 boolean updateSampleInfo(String user, String password)
          Query RLIMS for updated CaptureKit and RLIMSProjectID information for existing Sequenced Samples, and update them
 int updateSecondaryProjects(String user, String password)
          Iterate over the SecondaryProjectInformation table, looking for SecondaryProjects that do not have an Analysis group with a Beginning and Delivered Status.
static int verifyIndividual(String firstName, String lastName, Connection theConnection)
          If a person can be found in LDAP, add them to the DB and return true
 void writedatatofile(int connectid, String exportdata)
           
 
Methods inherited from class com.google.gwt.user.server.rpc.RemoteServiceServlet
getSerializationPolicy, processCall, processPost
 
Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
doPost
 
Methods inherited from class javax.servlet.http.HttpServlet
service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

kAttachToSample

public static final int kAttachToSample
Specifies that the key : value pair is about a sample

See Also:
Constant Field Values

kAttachToSequencedSample

public static final int kAttachToSequencedSample
Specifies that the key : value pair is about a sequenced sample

See Also:
Constant Field Values

kAttachToRun

public static final int kAttachToRun
Specifies that the key : value pair is about a run

See Also:
Constant Field Values

kAttachToUser

public static final int kAttachToUser
Specifies that the key : value pair is about a user

See Also:
Constant Field Values

kAttachToGroup

public static final int kAttachToGroup
Specifies that the key : value pair is about a Group

See Also:
Constant Field Values

kAttachToProject

public static final int kAttachToProject
Specifies that the key : value pair is about a Project

See Also:
Constant Field Values

kServletVersion

public static final int kServletVersion
Version given to callers of the servlet Web Page, as opposed to the GWT web page

See Also:
Constant Field Values

JVM_SYS_PROP_H2

public static final String JVM_SYS_PROP_H2
JVM system property that indicates whether the H2 database connection should be used instead of the MS SQL Server connection. Setting the value to "true" indicates that H2 will be used. Setting the value to "false" or omitting the property altogether indicates that MS SQL Server will be used.

See Also:
Constant Field Values

kJVMIsTunneled

public static final String kJVMIsTunneled
JVM system property that indicates whether using a tunneled connection to the primary DB, or else connecting directly

See Also:
Constant Field Values

kJVMIsDev

public static final String kJVMIsDev
JVM system property that indicates whether using Dev DB, or Prod DB

See Also:
Constant Field Values

kFastQSplitter

public static final String kFastQSplitter
String that divides the components of a FastQ File's name

See Also:
Constant Field Values

kFlowSplitter

public static final String kFlowSplitter
String that divides the flow cell information of a FastQ File's name

See Also:
Constant Field Values

kFastQCellInfoCol

public static final int kFastQCellInfoCol
The part of the FastQ or Flagstat file name that holds the flowcell information

See Also:
Constant Field Values

kWriteDir

public static final String kWriteDir
Where the upload servlets save data files

See Also:
Constant Field Values

kInvalidID

public static final int kInvalidID
An invalid DB ID

See Also:
Constant Field Values

kAlreadyExists

public static final int kAlreadyExists
Tried to add an item that is already in the DB

See Also:
Constant Field Values

kNumNegReturnCodes

public static final int kNumNegReturnCodes
Count of failure codes

See Also:
Constant Field Values

kAddSecondaryAnalysis

public static final String kAddSecondaryAnalysis
Parameter that says we're doing Add the Secondary Analysis

See Also:
Constant Field Values

kAppNameQuery

public static final String kAppNameQuery
Application that did the Secondary Analysis

See Also:
Constant Field Values

kVersion

public static final String kVersion
Version of the analysis

See Also:
Constant Field Values

kStatusQuery

public static final String kStatusQuery
Status of the analysis

See Also:
Constant Field Values

kAnalysisDate

public static final String kAnalysisDate
Date Analysis was done

See Also:
Constant Field Values

kFlowCell

public static final String kFlowCell
Flow cell the run was run on

See Also:
Constant Field Values

kIndexQuery

public static final String kIndexQuery
Index sequence for the sample, if any

See Also:
Constant Field Values

kLanesQuery

public static final String kLanesQuery
Lanes the analysis was run on, none for all lanes

See Also:
Constant Field Values

kCompleteQuery

public static final String kCompleteQuery
Parameter to include if analysis is complete

See Also:
Constant Field Values

kFailedQuery

public static final String kFailedQuery
Parameter to include if analysis failed

See Also:
Constant Field Values

kRunQuery

public static final String kRunQuery
Name of the run the analysis was done on

See Also:
Constant Field Values

kAnalysisName

public static final String kAnalysisName
Name of the Analysis Project the AnalysisGroup belongs to

See Also:
Constant Field Values

kUserParam

public static final String kUserParam
Database user name

See Also:
Constant Field Values

kPasswordParam

public static final String kPasswordParam
On encoded byte of the password per parameter

See Also:
Constant Field Values

kGetUserRuns

public static final String kGetUserRuns
Query Parameter to tell the servlet to retrieve the runs accessible by a given user

See Also:
Constant Field Values

kUploadData

public static final String kUploadData
Query Parameter to tell the servlet to load one or more data files

See Also:
Constant Field Values

kUserName

public static final String kUserName
URL Parameter for the lan id of the user who will own this run

See Also:
Constant Field Values

kPassword

public static final String kPassword
URL Parameter for the password of the user who will own this run

See Also:
Constant Field Values

kConnection

public static final String kConnection
URL Parameter for the connectionID to decode the password of the user

See Also:
Constant Field Values

kRunName

public static final String kRunName
The RLIMS name for the run

See Also:
Constant Field Values

kSampleName

public static final String kSampleName
The Sample Name

See Also:
Constant Field Values

kQCRunInformation

public static final String kQCRunInformation
Information about the QC Run

See Also:
Constant Field Values

kQCDataFile

public static final String kQCDataFile
The file that contains the QC information

See Also:
Constant Field Values

kReAnalysisType

public static final String kReAnalysisType
Project Type for a ReAnalysis Project

See Also:
Constant Field Values

kValidCopyRoles

public static final String[] kValidCopyRoles
Roles that can be granted to a user via copyUserPermissions ()

Constructor Detail

NGSPortalServiceImpl

public NGSPortalServiceImpl()
Default constructor.


NGSPortalServiceImpl

public NGSPortalServiceImpl(Authenticator authenticator,
                            edu.mayo.commons.dir.PersonFinder personFinder)
Constructor

Parameters:
authenticator -
personFinder -
Method Detail

init

public void init()
Initialize settings from the properties file, then setup the connections pool for the default user id.

Overrides:
init in class javax.servlet.GenericServlet

isTesting

public static final boolean isTesting()
Returns:
True if we are doing unit testing, else false

getConnection

public ConnectionResponse getConnection()
Give the client the information it needs in order to send data to the server

Specified by:
getConnection in interface NGSPortalService
Returns:
A ConnectionResponse object with the relevant information

logIn

public ConnectionResponse logIn(String lanID,
                                String password,
                                int connectID)
Tell the server the lanID and Password (encrypted) of the person doing the querying, and get told by the server if the lan ID and password are valid

Specified by:
logIn in interface NGSPortalService
Parameters:
lanID - User's lanID
password - User's password, encrypted to the server's specifications
connectID - The unique ID of the connection, so server can track multiple connection at the same time.
Returns:
Updated ConnectionResponse if user logged in successfully, else null

logOut

public void logOut(String userName,
                   String password,
                   int connectID)
Tell the server to forget about this user, and the user's current connection

Specified by:
logOut in interface NGSPortalService
Parameters:
userName - User's lanID
password - User's password, encrypted to the server's specifications
connectID - The unique ID of the connection, so server can track multiple connection at the same time.

makeSQLSafe

public static final String makeSQLSafe(String tested)
Utility routine for the common String test

Parameters:
tested - String to test
Returns:
Empty string if string is null or empty. Otherwise a string where every character that's not a letter, a digit, '_', '-', or ' ' is replaced with '_'

isEmpty

public static final boolean isEmpty(String tested)
Utility routine for the common String test

Parameters:
tested - String to test
Returns:
True if string is null or empty

getApplicationTypes

public List<String> getApplicationTypes()
Description copied from interface: NGSPortalService
Get the Descriptions for each of the application types the database recognizes

Specified by:
getApplicationTypes in interface NGSPortalService
Returns:
List of Strings, one description per string

getApplicationTypes

public List<String> getApplicationTypes(String runID,
                                        String pi)
Description copied from interface: NGSPortalService
Get the Descriptions for each of the application types the database recognizes, that occur with the specified PI and / or runID

Specified by:
getApplicationTypes in interface NGSPortalService
Parameters:
runID - Name of the run of interest, or null if don't care
pi - LanID of the PI of interest, or null if don't care
Returns:
List of Strings, possibly empty (if PI doesn't have any samples in runID), never null

getApplicationTypesForSamples

public int getApplicationTypesForSamples(int[] sampleIDs)
Description copied from interface: NGSPortalService
Gets the ID of the Application Type for more of the passed in samples than anyone else

Specified by:
getApplicationTypesForSamples in interface NGSPortalService
Parameters:
sampleIDs - Array of SequencedSample IDs, must not be empty or null
Returns:
DB ID of the Application Type, or -1 if there was a problem

getReadTypes

public List<String> getReadTypes()
Description copied from interface: NGSPortalService
Get the Descriptions for each of the read types the database recognizes

Specified by:
getReadTypes in interface NGSPortalService
Returns:
List of Strings, one description per string

getFileLocations

public List<FileLocation> getFileLocations()
Get a List of the available FileLocations that files might be saved in

Specified by:
getFileLocations in interface NGSPortalService
Returns:
List of FileLocation objects, or null if there was a problem

getAnalysisTypes

public List<String> getAnalysisTypes()
Description copied from interface: NGSPortalService
Get the names for each of the analysis types the database recognizes

Specified by:
getAnalysisTypes in interface NGSPortalService
Returns:
List of Strings, one name per string

getAnalysisStatuses

public List<String> getAnalysisStatuses()
Description copied from interface: NGSPortalService
Get the names for each of the analysis statuses the database recognizes

Specified by:
getAnalysisStatuses in interface NGSPortalService
Returns:
List of Strings, one status per string

getPrimaryAnalysisStatuses

public List<String> getPrimaryAnalysisStatuses()
Description copied from interface: NGSPortalService
Get the names for each of the Primary Analysis Statuses the database recognizes

Specified by:
getPrimaryAnalysisStatuses in interface NGSPortalService
Returns:
List of Strings, one name per string

getRoles

public List<String> getRoles()
Description copied from interface: NGSPortalService
Get all the Contact Roles in the database

Specified by:
getRoles in interface NGSPortalService
Returns:
List of Strings, one role ID per string

getPINames

public List<String> getPINames()
Description copied from interface: NGSPortalService
Get the names of all the PIs in the database

Specified by:
getPINames in interface NGSPortalService
Returns:
List of names, in the form Last Name, First Name

getPIForSamples

public int getPIForSamples(int[] sampleIDs)
Description copied from interface: NGSPortalService
Gets the ContactLinker ID of the Contact who is the PI for more of the passed in samples than anyone else

Specified by:
getPIForSamples in interface NGSPortalService
Parameters:
sampleIDs - Array of SequencedSample IDs, must not be empty or null
Returns:
DB ID of the Contact, or -1 if there was a problem

getRunIDs

public List<String> getRunIDs(int connectionID)
                       throws ConnectionException
Description copied from interface: NGSPortalService
Get all the run IDs in the database this user can see

Specified by:
getRunIDs in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
Returns:
List of Strings, one run ID per string
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getRunIDs

public List<String> getRunIDs(int connectionID,
                              String pi,
                              String appType)
                       throws ConnectionException
Description copied from interface: NGSPortalService
Get all the run IDs in the database this user can see, that have at least one sample that has the specified PI and / or application type

Specified by:
getRunIDs in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
pi - LanID of the PI of interest, or null if don't care
appType - Description of the application type of interest, or null if don't care
Returns:
List of Strings, possibly empty (if PI doesn't have any samples in runID), never null
Throws:
ConnectionException

getMatchingRuns

public List<ResultInfo> getMatchingRuns(int connectionID,
                                        String piName,
                                        String runID,
                                        String sample,
                                        String application,
                                        String rlimsProject,
                                        String rlimsID,
                                        Date startDate,
                                        Date endDate,
                                        boolean onlyAnalyzed,
                                        String projName)
                                 throws ConnectionException
Description copied from interface: NGSPortalService
Search the database for all the runs matching the criteria given, and return them

Specified by:
getMatchingRuns in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
piName - If not empty or null, the Last Name, First Name of the PI to look for
runID - If not empty or null, the single run ID to return
sample - If not empty or null, the name of the samples to return
application - If not empty or null, the type of application to search for
rlimsProject - If not empty or null, the RLIMS Project Name to search for
rlimsID - If not empty or null, the Run RLIMS BatchID to search for
startDate - If not null, lower bound on date range or allowed results
endDate - If not null, upper bound on date range or allowed results If startDate == endDate, will only return runs from that date.
onlyAnalyzed - If true, only find results where there's at least one secondary analysis available
projName - If not empty or null, the secondary project name to look for
Returns:
List of runs and samples that match the criteria, or an empty list if no matches
Throws:
ConnectionException

getReport

public List<ReportData> getReport(int connectionID,
                                  String piName,
                                  String instrument,
                                  int appType,
                                  Date minStartDate,
                                  Date maxStartDate,
                                  Date minEndDate,
                                  Date maxEndDate)
                           throws ConnectionException
Get a report on the runs specified by the following criteria

Parameters:
connectionID - ID of the connection, used to retrieve the PortalConnection. Must match the session connection ID, if the session connection ID exists
piName - Name of PI to restrict on, empty or null if don't care
instrument - Name of the instrument to restrict on, empty or null if don't care
appType - Application type to restrict on, < 0 if don't care
minStartDate - Earliest the run could have started, null if don't care
maxStartDate - Latest the run could have started, null if don't care
minEndDate - Earliest the run could have ended, null if don't care
maxEndDate - Latest the run could have ended, null if don't care
Returns:
List of ReportData objects, or null if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getRetainedSamples

public List<ResultInfo> getRetainedSamples(int connectionID,
                                           String piName,
                                           String runID,
                                           String sample,
                                           boolean isPrimary)
                                    throws ConnectionException
Get all the runs and samples that have data files that are currently marked for non-deletion

Specified by:
getRetainedSamples in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
piName - The Last Name, First Name of the PI to look for, or null if not restricting on that
runID - The run ID we're interested in, null or empty if not restricting on that
sample - Name of the sample we're searching for
isPrimary - True if want to know about primary analysis files, false if want to know about secondary analysis files
Returns:
List of runs and samples that match the criteria, or an empty list if no matches
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

retainSample

public boolean retainSample(int connectionID,
                            Date deleteDate,
                            String piName,
                            List<String> runIDs,
                            String sample,
                            String requestor,
                            boolean isPrimary)
                     throws ConnectionException
Mark a sample or set of samples as needing their data files to be retained

Specified by:
retainSample in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know that user has write access
deleteDate - New deletion date for the sample(s)
piName - The Last Name, First Name of the PI who owns the samples, or null if not restricting on that
runIDs - The run IDs we're interested in, list must not be null or empty
sample - Name of the sample we're updating, null for all samples on that run
requestor - Person making the update request. If user is not an "all access" user, this is ignored, and the user's name is used
isPrimary - True if want to retain primary analysis files, false if want to retain secondary analysis files
Returns:
True if added successfully, else false if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getRunData

public RunData getRunData(int connectionID,
                          String piName,
                          String runID)
                   throws ConnectionException
Get all the metadata from a given run, owned by a given PI

Specified by:
getRunData in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
piName - The Last Name, First Name of the PI to look for, empty or null if don't care
runID - The run ID we're interested in
Returns:
RunData object with the metadata, or null if no run was found
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getSamples

public List<SampleInfo> getSamples(int connectionID,
                                   String piName,
                                   String runID,
                                   String appType,
                                   String projectName)
                            throws ConnectionException
Get all the information about all the samples from a given run, owned by a given PI

Specified by:
getSamples in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
piName - The Last Name, First Name of the PI to look for
runID - The run ID we're interested in. One of this and projID can NOT be blank
appType - If not empty or null, The type of application to return
projectName - The name of the project we're interested in. One of this and runID can NOT be blank
Returns:
List of SampleInfo, possibly empty but never null
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

addExternalUser

public boolean addExternalUser(String firstName,
                               String lastName,
                               String id)
Add an external user to the database

Specified by:
addExternalUser in interface NGSPortalService
Parameters:
firstName - The new user's first name
lastName - The new user's last name
id - The new user's unique ID. Cannot match any id in the DB, or any Mayo LAN ID
Returns:
True if the id was unique, and were able to add the user to the DB, else false

grantUserAccess

public boolean grantUserAccess(int connectionID,
                               Map<String,Boolean> users,
                               int role,
                               String run,
                               List<String> samples)
                        throws ConnectionException
Routine to give users access to samples that the caller has access to

Specified by:
grantUserAccess in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
users - Map of the users being granted access to whether they're internal or not. For internal users, the String should be the user's lanID. For external, it needs to be a unique last name, first name
role - The role the Users are being given for these samples
run - The name of the run they're being granted access to
samples - List of samples from the run that the users are being granted access to, null or empty to grant access to all the samples of that run
Returns:
True if changed things successfully, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

revokeUserAccess

public boolean revokeUserAccess(int connectionID,
                                List<String> users,
                                String run,
                                List<String> samples)
                         throws ConnectionException
Routine to remove users' access to samples that the caller has PI access to, or where the caller has all sample access.

Specified by:
revokeUserAccess in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
users - List of the users losing access
run - The name of the run they're losing access to
samples - List of samples from the run that the users are losing access to, null or empty to revoke access to all the samples of that run
Returns:
True if changed things successfully, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

addUsersToProject

public boolean addUsersToProject(int connectionID,
                                 Map<String,Boolean> users,
                                 int role,
                                 String project)
                          throws ConnectionException
Give one or more users' access to a project

Specified by:
addUsersToProject in interface NGSPortalService
Parameters:
connectionID - The id of the person doing the add, must be part of Bioinformatics Staff
users - Map of the users being granted access to whether they're internal or not. For internal users, the String should be the user's lanID. For external, it needs to be a unique last name, first name
role - The role the Users are being given for this project
project - Name of the project the users are being added to
Returns:
True if changed things successfully, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

removeUsersFromProject

public boolean removeUsersFromProject(int connectionID,
                                      List<String> users,
                                      String project)
                               throws ConnectionException
Routine to remove one or more users' access to a project

Specified by:
removeUsersFromProject in interface NGSPortalService
Parameters:
connectionID - The id of the person doing the add, must be part of Bioinformatics Staff
users - List of the users losing access
project - The name of the project they're losing access to
Returns:
True if changed things successfully, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

grantProjectAccess

public boolean grantProjectAccess(int connectionID,
                                  String project,
                                  String run,
                                  List<String> samples)
                           throws ConnectionException
Routine to add samples to a project

Specified by:
grantProjectAccess in interface NGSPortalService
Parameters:
connectionID - The id of the person doing the add, must be part of Bioinformatics Staff
project - Name of the project getting access to the samples
run - The name of the run they're being granted access to
samples - List of samples from the run that are being added to the project, null or empty to grant access to all the samples of that run
Returns:
True if changed things successfully, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

revokeProjectAccess

public boolean revokeProjectAccess(int connectionID,
                                   String project,
                                   String run,
                                   List<String> samples)
                            throws ConnectionException
Routine to remove samples from a project

Specified by:
revokeProjectAccess in interface NGSPortalService
Parameters:
connectionID - The id of the person doing the remove, must be part of Bioinformatics Staff
project - Name of the project losing access to the samples
run - The name of the run the project is losing access to
samples - List of samples from the run that the project is losing access to, null or empty to revoke access to all the samples of that run
Returns:
True if changed things successfully, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

addGroup

public int addGroup(int connectionID,
                    String name,
                    String description)
             throws ConnectionException
Adds a new group

Specified by:
addGroup in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
name - Name of the new group. Must be unique
description - The group description
Returns:
ID of the new group, or -1 if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

updateGroup

public boolean updateGroup(int connectionID,
                           int groupID,
                           String name,
                           String description)
                    throws ConnectionException
Updates information about an existing group

Specified by:
updateGroup in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
groupID - The DB ID for the group
name - The group name
description - The group description
Returns:
True if successfully updated the group, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

deleteGroup

public boolean deleteGroup(int connectionID,
                           int groupID)
                    throws ConnectionException
Delete an existing group, and all related information

Specified by:
deleteGroup in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
groupID - The DB ID for the group
Returns:
True if successfully deleted the group, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

addUsersToGroup

public boolean addUsersToGroup(int connectionID,
                               int groupID,
                               Map<String,Integer> users)
                        throws ConnectionException
Add users to an existing group

Specified by:
addUsersToGroup in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
groupID - The DB ID for the group
users - Map holding the users' lanIDs and roles
Returns:
True if successfully updated the group, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

removeUsersFromGroup

public boolean removeUsersFromGroup(int connectionID,
                                    int groupID,
                                    List<String> users)
                             throws ConnectionException
Remove users from a group

Specified by:
removeUsersFromGroup in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
groupID - The DB ID for the group
users - List holding the lanIDs of the users being removed from the group
Returns:
True if successfully updated the group, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getGroups

public List<GroupInfo> getGroups(int connectionID)
                          throws ConnectionException
Get the list of all the groups in the DB

Specified by:
getGroups in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
Returns:
List of all the Groups in the DB
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

addKeyValuePair

public boolean addKeyValuePair(int connectionID,
                               int table,
                               String name,
                               String more,
                               String key,
                               String value)
                        throws ConnectionException
Add a Key : Value pair about a specified item to the DB

Specified by:
addKeyValuePair in interface NGSPortalService
Parameters:
connectionID - The user's connection ID. Must be part of Informatics staff
table - Specifier for which table to attach the data to
name - Unique specifier for the table of interest
more - Additional data to create a unique specifier for the table of interest, or null if don't need it
key - Key of the key : Value pair to add
value - Value of the key : Value pair to add
Returns:
True if added the Key: Value pair to the DB, false if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

addToFamily

public boolean addToFamily(int connectionID,
                           String family,
                           String parentID,
                           String rlimsID,
                           String sampleParentID,
                           String name,
                           Boolean isMale)
                    throws ConnectionException
Add a sample to a family, creating the family if necessary.

Specified by:
addToFamily in interface NGSPortalService
Parameters:
connectionID - The user's connection ID. Must be part of Informatics staff
family - The name of the family, each family has a unique name
parentID - The RLIMS ID of a sample belonging to a parent who is part of this family. The method will fail if the sample ID is not null and the sample doesn't exist, or if the sample is not part of the family
rlimsID - The RLIMS Family ID of the sample being added to the family
sampleParentID - The RLIMS Parent ID of the sample being added to the family
name - Name of the sample being added to the family, can be null or empty
isMale - True if male, false if female, null if not known
Returns:
True if added the sample to the family, false if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

removeFromFamily

public boolean removeFromFamily(int connectionID,
                                String family,
                                String rlimsID,
                                String parentID)
                         throws ConnectionException
Remove a sample from a family

Specified by:
removeFromFamily in interface NGSPortalService
Parameters:
connectionID - The user's connection ID. Must be part of Informatics staff
family - The name of the family, each family has a unique name
rlimsID - The RLIMS family ID of the sample being removed from the family
parentID - The RLIMS parent ID of the sample being removed from the family
Returns:
True sample was part of the family, and isn't any more, false if there was a problem, or if the sample was not part of the family to begin with
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getSampleNames

public List<SampleInfo> getSampleNames(int connectionID,
                                       String piName,
                                       String runID)
                                throws ConnectionException
Get all the information about all the samples from a given run, owned by a given PI

Specified by:
getSampleNames in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
piName - The Last Name, First Name of the PI to look for
runID - The run ID we're interested in
Returns:
List of SampleInfo, possibly empty but never null
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getSampleNames

public List<String> getSampleNames(int connectionID)
                            throws ConnectionException
Get the names of all the samples in the DB

Specified by:
getSampleNames in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
Returns:
List of String, possibly empty but never null, holding the sample name
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getRLIMSProjectNames

public List<String> getRLIMSProjectNames(int connectionID)
                                  throws ConnectionException
Get all the RLIMS project names in the database that this user can see

Specified by:
getRLIMSProjectNames in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
Returns:
List of names
Throws:
ConnectionException

getRLIMSIDs

public List<String> getRLIMSIDs(int connectionID)
                         throws ConnectionException
Get all the RLIMS Sample "Sample IDs" in the database that this user can see

Specified by:
getRLIMSIDs in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
Returns:
List of names
Throws:
ConnectionException

getCompletedRuns

public List<RunData> getCompletedRuns(int connectionID,
                                      String piName,
                                      String runID)
                               throws ConnectionException
Get all the completed runs

Specified by:
getCompletedRuns in interface NGSPortalService
Parameters:
connectionID - ID of the connection, used to retrieve the PortalConnection. Must match the session connection ID, if the session connection ID exists
piName - The Last Name, First Name of the PI to look for, empty or null if don't care
runID - The run ID we're interested in, empty or null if want all completed runs
Returns:
List of the runs, could be empty. Null if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

setRunData

public boolean setRunData(int connectionID,
                          String piName,
                          String runID,
                          RunData theRun,
                          List<SampleInfo> samples,
                          int[] deletedIDs)
                   throws ConnectionException
Update all the metadata for a given run, owned by a given PI

Specified by:
setRunData in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
piName - The Last Name, First Name of the PI to look for
runID - The run ID we're interested in
theRun - The updated run metadata, or null if no change to that data
samples - The changed samples for the this run - PI pair
deletedIDs - Array of the ids of Samples that were deleted, null if none were deleted
Returns:
True if changed things successfully, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getQCResults

public List<QCResult> getQCResults(int connectionID,
                                   String sampleName,
                                   String runID)
                            throws ConnectionException
Get all the information about the QCResults for a sample from a given run

Specified by:
getQCResults in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
sampleName - The name of the Sample to look for
runID - The run ID we're interested in
Returns:
List of QCResult, possibly empty, null if cannot connect to the DB or if sampleName or runID is empty or null
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getInstrumentHistory

public List<InstrumentInfo> getInstrumentHistory(int connectionID,
                                                 String instrument)
                                          throws ConnectionException
Get all the actions recorded for the given instrument

Specified by:
getInstrumentHistory in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
instrument - The name of the instrument to look up
Returns:
List of the Instrument's history, in sorted order, or null if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getInstrumentStatus

public Map<String,String> getInstrumentStatus(int connectionID)
                                       throws ConnectionException
Query the Primary Analysis DB for the runs that have completed the given task, and when they did it

Specified by:
getInstrumentStatus in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
Returns:
Map of runs and their dates, or null if there was a problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getSecondaryAnalysisResults

public List<Analysis2> getSecondaryAnalysisResults(int connectionID,
                                                   Date finishedCutoff)
                                            throws ConnectionException
Get all the information about the Secondary Analysis results for a sample from a given run

Specified by:
getSecondaryAnalysisResults in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
finishedCutoff - The cutoff date for finished runs (i.e. only report on finished runs that finished at or after this date). Defaults to one week ago if is null
Returns:
List of Analysis2, possibly empty but never null
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getAnalyzedSamples

public List<AnalysisInfo> getAnalyzedSamples(int connectionID,
                                             String theRun)
                                      throws ConnectionException
Description copied from interface: NGSPortalService
Finds all the samples for a run that have had an analysis done

Specified by:
getAnalyzedSamples in interface NGSPortalService
Parameters:
connectionID - ID of the connection, used to retrieve the PortalConnection. Must match the session connection ID, if the session connection ID exists
theRun - The run whose samples we're looking at
Returns:
List of the samples. As this can only be called when one or more of the run's samples has been analyzed, the list should never be empty
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

parseRunFile

public boolean parseRunFile(String filePath,
                            String user,
                            String password)
Parses the passed in file. If it's a directory, parses all the .xml files in that directory, or in any of its sub-directories. Ignores any runs already in the DB.

Specified by:
parseRunFile in interface NGSPortalService
Parameters:
filePath - XML file or directory to use
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
True if everything was successful, else false

parseQCFolder

public boolean parseQCFolder(String folderPath,
                             String user,
                             String password)
Parses the passed in directory, parses all the fastqc_data.txt files in that directory, or in any of its sub-directories. If they are new, adds them to the DB

Parameters:
folderPath - Directory holding the run's QC Files, or directory holding run directories
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
True if everything was successful, else false

parseQCFolder

public boolean parseQCFolder(String folderPath,
                             String[] runNames,
                             String user,
                             String password)
Parses the passed in file. If it's a directory, parses all the fastqc_data.txt files in that directory, or in any of its sub-directories. If they are new, adds them to the DB

Parameters:
folderPath - Directory holding the run's QC Files, or directory holding run directories
runNames - Names of runs to restrict the parsing to, else null if should parse all
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
True if everything was successful, else false

findUnmatchedRuns

public Set<String> findUnmatchedRuns(String[] testPaths)
Find any runs in the DB that have samples with Flagstat data, where there isn't a run folder with Flagstat files in any of the testPaths

Parameters:
testPaths - Paths to directories that should hold a lot of runs with Flagstat files
Returns:
Set of Runs that are trouble

parseRLIMS

public boolean parseRLIMS(String user,
                          String password)
Parses the entire RLIMS system. Ignores runs that are already in the DB.

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
True if everything was successful, else false

parseRLIMSRun

public boolean parseRLIMSRun(String[] runNames,
                             String user,
                             String password)
Gets the data about a list of runs from RLIMS, and adds any new runs or samples to the DB

Parameters:
runNames - Names of the runs to get all samples from
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
True if everything was successful, else false

addRLIMSBatchIDs

public boolean addRLIMSBatchIDs(String user,
                                String password)
Gets the runs that don't have RLIMS Batch IDs, and looks for the IDs, adding them if they exist

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
True if everything was successful, else false

compareToRLIMS

public boolean compareToRLIMS(String user,
                              String password)
Parses the entire RLIMS system, checking to find those runs where we don't have as many samples for a run as RLIMS does

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
True if everything was successful, else false

addLocationInformation

public boolean addLocationInformation(String[] pis,
                                      String[] runs,
                                      String[] flowCells,
                                      int[] lanes,
                                      String[] indexes,
                                      String[] locations,
                                      String[] sizes,
                                      String user,
                                      String password)
Add location information to the Sequenced Sample table

Parameters:
pis - Array holding the pi names, must be same length as other six arrays
runs - Array holding the run names, must be same length as other six arrays
flowCells - Array holding the flowCell names, must be same length as other six arrays
lanes - Array holding the lanes, must be same length as other six arrays
indexes - Array holding the indexes, must be same length as other six arrays
locations - Array holding the locations for the given run and sample names, must be same length as other six arrays
sizes - Array holding the file sizes as strings, or null if not given for any given
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
True if added successfully, false if there was a problem

addMetadata

public boolean addMetadata(String[] pis,
                           String[] runs,
                           String[] flowCells,
                           String[] sampleNames,
                           String[] familyIDs,
                           String[] parentIDs,
                           String[] rlimsIDs,
                           int[] lanes,
                           String[] indexes,
                           String[] readTypes,
                           String[] apps,
                           int[] cycles,
                           String user,
                           String password)
Add metadata to the DB. All the arrays passed in must be the same length

Parameters:
pis - Array holding the pi names
runs - Array holding the run names
flowCells - Array holding the flowCell names
sampleNames - Array holding the sample names
familyIDs - Array holding the Sample Family IDs
parentIDs - Array holding the Sample Parent IDs
rlimsIDs - Array holding the RLIMS IDs
lanes - Array holding the lane numbers
indexes - Array holding the indexes
readTypes - Array holding the read types
apps - Array holding the application names
cycles - Array holding the number of cycles the sample were run through
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
True if added successfully, false if there was a problem

updateRunDates

public boolean updateRunDates(String user,
                              String password)
Query the Primary Analysis database for information about run primary analysis dates

Parameters:
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
false if had a failure trying to update the DB, else true

updateSampleInfo

public boolean updateSampleInfo(String user,
                                String password)
Query RLIMS for updated CaptureKit and RLIMSProjectID information for existing Sequenced Samples, and update them

Parameters:
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
false if had a failure trying to update the DB, else true

updateSampleIDInfo

public boolean updateSampleIDInfo(String user,
                                  String password)
Query the Dev DB for Sample ID and Ultimate Parent ID information for existing production Sequenced Samples, and update the production Sequenced Samples and their samples

Parameters:
user - user ID to give to the DB, in order to get write permission
password - password to give to the DB, in order to get write permission
Returns:
false if had a failure trying to update the DB, else true

updateAnalysis

public boolean updateAnalysis(String analysisPath,
                              String uID,
                              String password)
Description copied from interface: NGSPortalService
Update the database with all the new analyses that have been added

Specified by:
updateAnalysis in interface NGSPortalService
Parameters:
analysisPath - The path to where the analysis results are located
uID - The user ID to use when modifying the database
password - The password to use when modifying the database
Returns:
True if added successfully, else false

addNote

public boolean addNote(int connectionID,
                       String note,
                       String tableName,
                       int rowID)
                throws ConnectionException
Adds a note to the database

Specified by:
addNote in interface NGSPortalService
Parameters:
connectionID - ID of the connection, used to retrieve the PortalConnection. Must match the session connection ID, if the session connection ID exists
note - The Note
tableName - Name of the table the note's about
rowID - The id of the item in the table the note is about
Returns:
True if added the note, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getNote

public List<Note> getNote(int connectionID,
                          String tableName,
                          int rowID)
                   throws ConnectionException
Get one or more notes from the database

Specified by:
getNote in interface NGSPortalService
Parameters:
connectionID - ID of the connection, used to retrieve the PortalConnection. Must match the session connection ID, if the session connection ID exists
tableName - Name of the table we're looking for notes for, null or empty string to get notes for all tables
rowID - The row id of the item in the table that we're looking for notes for, or kInvalidID to get the notes for all the items for table tableName
Returns:
List of notes that match the criteria (which might be empty) or null if there was a non-connection problem
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

deleteNote

public boolean deleteNote(int connectionID,
                          String tableName,
                          int rowID,
                          Date noteDate)
                   throws ConnectionException
Description copied from interface: NGSPortalService
Deletes a note from the database.

Specified by:
deleteNote in interface NGSPortalService
Parameters:
connectionID - ID of the connection, used to retrieve the PortalConnection. Must match the session connection ID, if the session connection ID exists
tableName - Name of the table we're looking for notes for, null or empty string to get notes for all tables
rowID - The row id of the item in the table that we're looking for notes for, or kInvalidID to get the notes for all the items for table tableName
noteDate - The date of the note
Returns:
True if deleted the note, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

createAnalysisGroup

public int createAnalysisGroup(String analysisName,
                               String runName,
                               String flowCell,
                               String index,
                               int[] lanes,
                               String user,
                               String password)
Add an Analysis Group to the DB, setting up all the relevant information

Parameters:
analysisName - The name of the analysis project to be added to. May be null, may not be empty
runName - The RunID of the run the analysis was done for
flowCell - Name of the flowCell the samples were run in, null for don't care
index - Index of the sequence, empty to specify no index, null if don't care what the index is
lanes - Lane(s) the analyzed samples were run, null or empty to get all samples in the Run
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
ID of created group, or -1 if failed to create the group

testSecondaryProjectMembership

public String testSecondaryProjectMembership(String projectName,
                                             String runName,
                                             String flowCell,
                                             String index,
                                             int[] lanes,
                                             String user,
                                             String password)
Verify that the specified samples are all in the specified project

Parameters:
projectName - The name of the Secondary Project we're testing the samples against
runName - The RunID of the run the analysis was done for
flowCell - Name of the flowCell the samples were run in, null for don't care
index - Index of the sequence, empty to specify no index, null if don't care what the index is
lanes - Lane(s) the analyzed samples were run, null or empty to get all samples in the Run
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Null if everything was correct, a string listing the incorrect samples if there's a problem

createAnalysisGroup

public int createAnalysisGroup(int connectionID,
                               String analysisName,
                               String runName,
                               String flowCell,
                               String index,
                               int[] lanes)
                        throws ConnectionException
Add an Analysis Group to the DB, setting up all the relevant information

Parameters:
connectionID - The user's connection ID
analysisName - The name of the analysis project to be added to. May be null, may not be empty
runName - The RunID of the run the analysis was done for
flowCell - Name of the flowCell the samples were run in, null for don't care
index - Index of the sequence, empty to specify no index, null if don't care what the index is
lanes - Lane(s) the analyzed samples were run, null or empty to get all samples in the Run
Returns:
ID of created group, or -1 if failed to create the group
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

addSampleAnalysis

public boolean addSampleAnalysis(String projectName,
                                 String appName,
                                 double version,
                                 String status,
                                 Date analysisDate,
                                 String user,
                                 String password,
                                 boolean complete,
                                 boolean failed)
Add a Secondary analysis to the DB, setting up all the relevant information

Parameters:
projectName - The name of the Secondary Project this analysis belongs to
appName - The tool name of the analysis to be added
version - The version of the tool that was used
status - The status of this analysis
analysisDate - The date the analysis was finished
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
complete - True if all analysis is done for this sample and run, else false
failed - True if the analysis failed, else false
Returns:
True if was successful, else false

copyUserPermissions

public String copyUserPermissions(String sourceUser,
                                  String sourceUserRole,
                                  String[] targetUsers,
                                  String targetUserRole,
                                  String sourceRun,
                                  String sourceFlowcell,
                                  int sourceLane,
                                  String sourceIndex,
                                  String targetRun,
                                  String targetFlowcell,
                                  int targetLane,
                                  String targetIndex,
                                  String user,
                                  String password)
Copies user permissions (i.e. userRole settings) from one sample to other samples, or from one user to other users.

Usage:
1: Give members of a lab access to all the PI's samples:
sourceUser: [PI LanID], sourceUserRole: "PI", targetUsers: [Array of LanID], targetUserRole: Researcher

2: Copy permissions from one sample to all the other samples in a run:
sourceFlowcell: [Sample Flowcell], sourceLane: [Sample Lane], sourceIndex: [Sample Index], targetRun: [Target Run Name]

3: Copy permissions from one sample to one or more other samples:
sourceFlowcell: [Sample Flowcell], sourceLane: [Sample Lane], sourceIndex: [Sample Index], targetFlowcell: [Target Flowcell], targetLane: [Target Lane], targetIndex [Target Index]

In cases 2 and 3 it is the user's responsibility to insure that the Sample information is sufficient to uniquely specify one sample.

Parameters:
sourceUser - User to copy permissions from, or null if not doing that
sourceUserRole - Role of the user when getting target samples, or null if not doing that
targetUsers - Array of users to give permissions to, or null if not doing that
targetUserRole - Role to give the users on the specified samples, or null if not doing that. Can not be "PI" or one of the privileged roles (like Informatics Specialist)
sourceRun - Run to get the source sample from. May be null or empty
sourceFlowcell - Flowcell of the source sample. May be null or empty
sourceLane - Lane of the source sample. May be 0 to be ignored
sourceIndex - Index of the source sample. May be null or empty
targetRun - Run to get the target sample(s) from. May be null or empty
targetFlowcell - Flowcell of the target sample(s). May be null or empty
targetLane - Lane of the target sample(s). May be 0 to be ignored
targetIndex - Index of the target sample(s). May be null or empty
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
String describing the reason why it failed, or announcing that it succeeded

getRunsSamples

public List<SampleData> getRunsSamples(String[] runIDs,
                                       String appType,
                                       String pi,
                                       String[] sampleNames,
                                       String[] sampleRLIMSIds,
                                       String[] sampleFamilyIds,
                                       String[] sampleParentIds,
                                       String[] rlimsProjectNames,
                                       Date startDate,
                                       Date endDate,
                                       int minNumReads,
                                       String user,
                                       String password)
Get all the information about all the samples from a given run, owned by a given PI

Parameters:
runIDs - The run IDs we're interested in, or null if not filtering on run
appType - Application type to filter on, null to not filter
pi - LanID of PI to filter on, null to not filter
sampleNames - Names of the sample(s) that we're interested in, null if not restricting on that
sampleRLIMSIds - RLIMS IDs of the sample(s) that we're interested in, null if not restricting on that
sampleFamilyIds - RLIMS Family ID of the sample(s) that we're interested in, null if not restricting on that
sampleParentIds - Root RLIMS IDs of the sample(s) that we're interested in, null if not restricting on that
rlimsProjectNames - RLIMS Project ID(s) of the sample(s) that we're interested in, null if not restricting on that
startDate - Start date, inclusive, for results, null if not restricting on that
endDate - End date, inclusive, for results, null if not restricting on that
minNumReads - Minimum number of reads for a sample restrict on, 0 if not restricting on that
user - User ID to give to the DB, in order to get read permission
password - Password to give to the DB, in order to get read permission
Returns:
List of SampleInfo, possibly empty but never null unless the call was bad

getAnalysisDates

public List<String> getAnalysisDates(Date startDate,
                                     Date endDate,
                                     String application,
                                     String[] runNames,
                                     String pi,
                                     boolean tabDelim,
                                     String user,
                                     String password)
Get a List of Strings, each one holding
Run Name Application Investigator CIM BIC Primary Delivered Secondary Complete Secondary Delivered
delimited with either a tab or a comma

Parameters:
startDate - If not null, lower bound on date range for allowed results
endDate - If not null, upper bound on date range for allowed results
application - Application type to filter on, null to not filter
runNames - Array of run names to restrict on, null not to filter on them
pi - LanID of PI to filter on, null to not filter
tabDelim - True if results are tab delimited, false to get comma delimited results
user - User ID to give to the DB, in order to get read permission
password - Password to give to the DB, in order to get read permission
Returns:
List of Strings, possibly empty but never null unless the call was bad

addSampleAnalysis

public boolean addSampleAnalysis(int connectionID,
                                 int groupID,
                                 String appName,
                                 double version,
                                 String status,
                                 Date analysisDate,
                                 boolean complete,
                                 boolean failed)
                          throws ConnectionException
Add a Secondary analysis to the DB, setting up all the relevant information

Parameters:
connectionID - The user's connection ID
groupID -
appName - The tool name of the analysis to be added
version - The version of the tool that was used
status - The status of this analysis
analysisDate - The date the analysis was finished
complete - True if all analysis is done for this sample and run, else false
failed - True if the analysis failed, else false
Returns:
True if was successful, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getFlowCell

public static final String getFlowCell(String[] split)
Get the flowCell from the split up components of the FastQ File name

Parameters:
split - The components of the second part of the name, split on '_'
Returns:
The flowCell, or "" if there is a problem

getLane

public static final int getLane(String[] split)
Get the lane from the split up components of the FastQ File name

Parameters:
split - The components of the second part of the name, split on '_'
Returns:
The lane, or 0 if there is a problem

getRead

public static final int getRead(String[] split)
A1-Input_hMeDIP.FCC3PBEACXX_L7_IACAGTG.flagstat fastqc/A1-Input_hMeDIP.FCC3PBEACXX_L7_R1_IACAGTG_fastqc/fastqc_data.txt* Get the read from the split up components of the FastQ File name

Parameters:
split - The components of the second part of the name, split on '_'
Returns:
The read, or 1 if there is a problem

getIndex

public static final String getIndex(String[] split)
Get the index from the split up components of the FastQ File name

Parameters:
split - The components of the second part of the name, split on '_'
Returns:
The index, or "" if there is no index, or there is a problem

verifyIndividual

public static int verifyIndividual(String firstName,
                                   String lastName,
                                   Connection theConnection)
If a person can be found in LDAP, add them to the DB and return true

Parameters:
firstName - First name of the person of interest
lastName - Last name of the person of interest
theConnection - Connection to the database to use when adding information
Returns:
The DB ID if found the individual on LDAP and added them to the DB, -1 if not

formatDate

public static String formatDate(Date theDate)
Format a date in the format that the servlet wishes to receive dates

Parameters:
theDate - Date to format. Will be set to today if null
Returns:
Date in the format yyy-MM-dd hh:mm:ss

moveSecAnToAnalysisGroups

public int moveSecAnToAnalysisGroups(String user,
                                     String password)
Iterate over the SecondaryAnalysisLinker table, adding all the secondary analyses there to the AnalysisGroup table

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Count of how many Analysis Groups were created

joinAnalysisGroups

public int joinAnalysisGroups(String user,
                              String password)
Iterate over the AnalysisGroup table, consolidating AnalysisGroups that are from the same run and PI, and have the same appType, so long as their start and end are within a couple of days of each other

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Count of how many Analysis Groups were created

assignAnalysisGroups

public int assignAnalysisGroups(String user,
                                String password)
Iterate over the AnalysisGroup table, looking for AnalysisGroups that are not assigned to a Secondary Project, but have the same sequenced samples as an existing Secondary Project, and assign the AnalysisGroup to the SecondaryProject

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Count of how many Analysis Groups were created

nameSecondaryProjects

public int nameSecondaryProjects(String user,
                                 String password)
Iterate over the SecondaryProjectInformation table, looking for SecondaryProjects that do not have a name and do have samples, and give them one based upon the run, appType, and PI associated with their samples

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Count of how many SecondaryProjectInformation entries were named

updateSecondaryProjects

public int updateSecondaryProjects(String user,
                                   String password)
Iterate over the SecondaryProjectInformation table, looking for SecondaryProjects that do not have an Analysis group with a Beginning and Delivered Status. For those Projects find any analysis Groups that point to their samples, and merge them together

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Count of how many SecondaryProjectInformation entries had changes made, or -1 if there was an error

findOverlappingSecondaryProjects

public int findOverlappingSecondaryProjects(String user,
                                            String password)
Iterate over the SecondaryProjectInformation table, looking for SecondaryProjects that do not have an Analysis group with a Beginning and Delivered Status. For those Projects find any analysis Groups that point to their samples, and merge them together

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Count of how many SecondaryProjectInformation entries had changes made, or -1 if there was an error

getReanalysisProjects

public int getReanalysisProjects(String user,
                                 String password)
Get all the secondary projects that don't have an analysis group pointing to them, and that share a set of samples with secondary projects that also don't have an analysis group pointing to them

Parameters:
user - User ID to give to the DB, in order to get write permission
password - Password to give to the DB, in order to get write permission
Returns:
Count of how many Secondary Project sets occur

addSecAnLinks

public boolean addSecAnLinks(int[][] mappings)
Add these sequenced samples and Secondary Analysis to the Secondary Analysis linker table

Parameters:
mappings - Array of entries: seqID secAnID
Returns:
True if added successfully, false if there was a problem

addProject

public String addProject(int connectionID,
                         String notes,
                         boolean isReanalysis,
                         int[] seqSampleIDs,
                         Integer leadID,
                         Integer specID,
                         Integer piID)
                  throws ConnectionException
Description copied from interface: NGSPortalService
Adds a new project.

Specified by:
addProject in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
notes - The project notes.
isReanalysis - Is this a reanalysis project.
seqSampleIDs - One or more sequenced sample IDs assigned to the project.
leadID - Contact user ID for the informatics lead, or null if none
specID - Contact user ID for the informatics specialist, or null if none
piID - Contact user ID for the PI, or null if none
Returns:
Name of the new project.
Throws:
ConnectionException

updateProject

public void updateProject(int connectionID,
                          String projectName,
                          String notes,
                          boolean isReanalysis,
                          int[] seqSampleIDs,
                          Integer leadID,
                          Integer specID,
                          Integer piID)
                   throws ConnectionException
Description copied from interface: NGSPortalService
Updates an existing project.

Specified by:
updateProject in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
projectName - Name of project to update.
notes - The project notes.
isReanalysis - Is this a reanalysis project.
seqSampleIDs - One or more sequenced sample IDs assigned to the project.
leadID - Contact user ID for the informatics lead
specID - Contact user ID for the informatics specialist
piID - Contact user ID for the PI
Throws:
ConnectionException

removeProject

public void removeProject(int connectionID,
                          String projectName)
                   throws ConnectionException
Description copied from interface: NGSPortalService
Removes an existing project.

Specified by:
removeProject in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
projectName - Name of project to remove.
Throws:
ConnectionException

getProjects

public List<SecondaryProjectInfo> getProjects(int connectionID,
                                              String projectName)
                                       throws ConnectionException
Description copied from interface: NGSPortalService
Get all the Secondary Projects created by this individual, or the single project projectName

Specified by:
getProjects in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
projectName - If not null, the name of the single project to get. Only will get if the user created the project, or has canEditAll authorization
Returns:
List of Secondary projects, or null if there was a problem
Throws:
ConnectionException

removeProject

public void removeProject(int connectionID,
                          int projID)
                   throws ConnectionException
Code to delete a Patrick style Project

Parameters:
connectionID - ID of the person making the request
projID - ID of the project to delete
Throws:
ConnectionException

getProjects

public List<ProjectInfo> getProjects(int connectionID,
                                     int[] projIDs)
                              throws ConnectionException
Description copied from interface: NGSPortalService
Gets one or more projects.

Specified by:
getProjects in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
projIDs - ID(s) of the projects to fetch. If empty or null, all projects are returned.
Returns:
List of projects, or null if there was a problem
Throws:
ConnectionException

getProjectNames

public List<String> getProjectNames(int connectionID)
                             throws ConnectionException
Description copied from interface: NGSPortalService
Get the names of all the secondary analysis projects in the database that this user can see

Specified by:
getProjectNames in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
Returns:
List of names
Throws:
ConnectionException

getPrimaryProjectNames

public List<String> getPrimaryProjectNames(int connectionID)
                                    throws ConnectionException
Get the names of all the projects in the database

Parameters:
connectionID - The user's connection ID
Returns:
List of names
Throws:
ConnectionException

getContacts

public List<ContactInfo> getContacts(int connectionID,
                                     int[] contactIDs)
                              throws ConnectionException
Description copied from interface: NGSPortalService
Gets one or more contacts.

Specified by:
getContacts in interface NGSPortalService
Parameters:
connectionID - The user's connection ID
contactIDs - ID(s) of the contacts to fetch. If empty or null, all contacts are returned.
Returns:
List of contacts, or null if there was a problem
Throws:
ConnectionException

getCurrentPrimaryStatus

public Map<String,PrimaryAnalysisBean> getCurrentPrimaryStatus(int connectionID)
                                                        throws ConnectionException
Get the latest primary analysis statuses, from all the primary analysis results that have been updated in the last week

Specified by:
getCurrentPrimaryStatus in interface NGSPortalService
Parameters:
connectionID - The id of the connection, so know what user has access to
Returns:
Map from run names to the latest primary analysis status information about that run
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

getValidRunTypes

public List<String> getValidRunTypes(int connectionID)
                              throws ConnectionException
Description copied from interface: NGSPortalService
Returns a list of possible Run Types (eg., exome, whole_genome,...) available

Specified by:
getValidRunTypes in interface NGSPortalService
Parameters:
connectionID - The user's connection ID.
Returns:
List of run types
Throws:
ConnectionException

getAvgCPUSecondsPerScript

public List<SGEScriptSummary> getAvgCPUSecondsPerScript(SGEFilter filter,
                                                        int connectionID)
                                                 throws ConnectionException
Description copied from interface: NGSPortalService
Queries the portal database and returns a list of SGEScriptSummary containing the average of cpuseconds consumed by the scripts defined by the provided SGEFilter

Specified by:
getAvgCPUSecondsPerScript in interface NGSPortalService
Parameters:
filter - An SGEFilter (null gives no filtering)
connectionID - The user's connection ID.
Returns:
List List of scripts and their average cpu seconds or null if not authorized or no data
Throws:
ConnectionException

getScriptInvocations

public List<SGEScriptSummary> getScriptInvocations(SGEFilter filter,
                                                   int connectionID)
                                            throws ConnectionException
Description copied from interface: NGSPortalService
Queries the portal database and returns a list of SGEScriptSummary containing the total script invocations in the runs defined by the provided SGEFilter

Specified by:
getScriptInvocations in interface NGSPortalService
Parameters:
filter - An SGEFilter (null gives no filtering)
connectionID - The user's connection ID.
Returns:
List List of scripts and the number of executions or null if not authorized or no data
Throws:
ConnectionException

getAvgRun

public List<SGEScriptSummary> getAvgRun(SGEFilter filter,
                                        int connectionID)
                                 throws ConnectionException
Description copied from interface: NGSPortalService
Queries the portal database and returns a list of SGEScriptSummary containing the sum of cpuseconds consumed by the scripts defined by the provided SGEFilter

Specified by:
getAvgRun in interface NGSPortalService
Parameters:
filter - An SGEFilter (null gives no filtering)
connectionID - The user's connection ID.
Returns:
List List of scripts and their total cpu seconds or null if not authorized or no data
Throws:
ConnectionException

getSumCPUSecondsPerScript

public List<SGEScriptSummary> getSumCPUSecondsPerScript(SGEFilter filter,
                                                        int connectionID)
                                                 throws ConnectionException
Description copied from interface: NGSPortalService
Queries the portal database and returns a list of SGEScriptSummary containing the sum of cpuseconds consumed by the scripts defined by the provided SGEFilter

Specified by:
getSumCPUSecondsPerScript in interface NGSPortalService
Parameters:
filter - An SGEFilter (null gives no filtering)
connectionID - The user's connection ID.
Returns:
List List of scripts and their total cpu seconds or null if not authorized or no data
Throws:
ConnectionException

getValidRLIMS

public List<String> getValidRLIMS(SGEFilter filter,
                                  int connectionID)
                           throws ConnectionException
Description copied from interface: NGSPortalService
Queries the portal database and returns a list of possible RunIDs falling within the provided SGEFilter

Specified by:
getValidRLIMS in interface NGSPortalService
Parameters:
filter - An SGEFilter (null gives no filtering)
connectionID - The user's connection ID.
Returns:
List List of RunIDs or null if none available
Throws:
ConnectionException

getWallClockPerRun

public Map<String,Double> getWallClockPerRun(SGEFilter filter,
                                             int connectionID)
                                      throws ConnectionException
Description copied from interface: NGSPortalService
Returns a set of pairs of WallClock times and RunIDs defined by the passed filter object.

Specified by:
getWallClockPerRun in interface NGSPortalService
Parameters:
filter - An SGEFilter (null gives no filtering)
connectionID - The user's connection ID.
Returns:
Map or null if no data available
Throws:
ConnectionException

getWallClockPerSample

public Map<String,Double> getWallClockPerSample(SGEFilter filter,
                                                int connectionID)
                                         throws ConnectionException
Description copied from interface: NGSPortalService
Returns a set of pairs of WallClock times and SampleIDs defined by the passed filter object.

Specified by:
getWallClockPerSample in interface NGSPortalService
Parameters:
filter - An SGEFilter (null gives no filtering)
connectionID - The user's connection ID.
Returns:
Map or null if no data available
Throws:
ConnectionException

getSamplesPerMonth

public Map<String,Integer> getSamplesPerMonth(SGEFilter filter,
                                              int connectionID)
                                       throws ConnectionException
Description copied from interface: NGSPortalService
Returns a set of pairs of months and unique samples defined by the passed filter object.

Specified by:
getSamplesPerMonth in interface NGSPortalService
Parameters:
filter - An SGEFilter(null gives no filtering)
connectionID - The user's connection ID.
Returns:
Map or null if no data available
Throws:
ConnectionException

getErrorsPerRun

public Map<String,Integer> getErrorsPerRun(SGEFilter filter,
                                           int connectionID)
                                    throws ConnectionException
Description copied from interface: NGSPortalService
Returns a set of pairs of RunIDs - ScriptNames and error counts defined by the passed filter object.

Specified by:
getErrorsPerRun in interface NGSPortalService
Parameters:
filter - An SGEFilter(null gives no filtering)
connectionID - The user's connection ID.
Returns:
Map or null if no data available
Throws:
ConnectionException

getSGEFlowcellsPerMonth

public Map<String,Integer> getSGEFlowcellsPerMonth(SGEFilter filter,
                                                   int connectionID)
                                            throws ConnectionException
Specified by:
getSGEFlowcellsPerMonth in interface NGSPortalService
Throws:
ConnectionException

getDefaultProjectName

public String getDefaultProjectName(String runName,
                                    String appType,
                                    String pi,
                                    boolean isReanalysis)
Description copied from interface: NGSPortalService
Get a default Secondary Project Reanalysis name from the server given the run, PI, and appType, then ask the user for the reanalysis name, given the default name

Specified by:
getDefaultProjectName in interface NGSPortalService
Parameters:
runName - Name of the run of interest
appType - Application type
pi - Name of the PI
isReanalysis - True if it's a reanalysis, false otherwise
Returns:
A unique Project name that matches the specified characteristics

getProjectsSummary

public ProjectSummaryBuilder getProjectsSummary(int connectionID,
                                                String userLanID,
                                                Date fromDate,
                                                Date toDate)
                                         throws ConnectionException
Specified by:
getProjectsSummary in interface NGSPortalService
Throws:
ConnectionException

getSecondaryStatus

public Map<String,List<SecondaryAnalysisBean>> getSecondaryStatus(int connectID)
                                                           throws ConnectionException
SQL query and result set to Return current Secondary Analysis status

Specified by:
getSecondaryStatus in interface NGSPortalService
Parameters:
connectID - The id of the connection, so know what user has access to
Throws:
ConnectionException

getAllSecondaryStatuses

public Map<String,Integer> getAllSecondaryStatuses()
Get the Secondary Analysis Statuses and their DB row IDs

Specified by:
getAllSecondaryStatuses in interface NGSPortalService
Returns:
Map of statuses, and where those status come in the progression from beginning to Delivered

sqlresultToSecondaryAnalysis

public Map<String,List<SecondaryAnalysisBean>> sqlresultToSecondaryAnalysis(ResultSet rs)
                                                                     throws SQLException
Converts Secondary Analysis Result set to SecondaryAnalysisBean

Parameters:
rs -
Returns:
Map from run names to Lists of SecondaryAnalysisBeans
Throws:
SQLException

sendEmailNotification

public void sendEmailNotification(int connectID,
                                  String runName,
                                  String application,
                                  String pi,
                                  String assignerLanID,
                                  String notes,
                                  String newAssignee,
                                  String oldAssignee,
                                  int projectID)
                           throws ConnectionException
Saves the Assigned Date and Personnel to the DB

Specified by:
sendEmailNotification in interface NGSPortalService
Parameters:
connectID - The user's connection ID
runName - The name of the run
application - The type of analysis to be run
pi - The PI the work is being done for
assignerLanID - The LAN ID of the person assigning the work
notes - Any notes for the analysis
newAssignee - The person being assigned to run the analysis
oldAssignee - The previous person assigned to do the analysis, or null if no one
projectID - ID of the project, so can send along its name
Throws:
ConnectionException

saveNotes

public void saveNotes(int connectID,
                      int projectID,
                      String runName,
                      String pI,
                      String application,
                      String personnel,
                      String newNotes)
               throws ConnectionException
Save Notes to the Database. Fails if user is neither an administrator or a member of the PI Support staff

Specified by:
saveNotes in interface NGSPortalService
Parameters:
connectID - The id of the connection, so know what user has access to
projectID - ID of the project we're adding notes about
runName - Name of the run we're adding notes about
pI - The PI the work is being done for
application - The type of analysis being run
personnel - LanID of the person doing the analysis
newNotes - New value of the notes field
Throws:
ConnectionException

getISdetails

public Map<String,String> getISdetails()
Get a map from LAN IDs to names for all the Informatics Specialists

Specified by:
getISdetails in interface NGSPortalService
Returns:
Map from Lan IDs to Names in the form "[last name], [first name]", or empty map if couldn't load it

saveSecondaryStartDate

public void saveSecondaryStartDate(int connectID,
                                   int projectID,
                                   Date date)
                            throws ConnectionException
Saves the Secondary Start Date

Specified by:
saveSecondaryStartDate in interface NGSPortalService
Parameters:
connectID - The id of the connection, so know what user has access to
Throws:
ConnectionException

saveBatched

public void saveBatched(int connectID,
                        int projectID,
                        String value)
                 throws ConnectionException
Saves the batched value

Specified by:
saveBatched in interface NGSPortalService
Throws:
ConnectionException

setIsBIC

public boolean setIsBIC(int connectionID,
                        boolean isBIC,
                        int projectID)
                 throws ConnectionException
Sets all the samples for a project to have their isBIC field either be true or false

Specified by:
setIsBIC in interface NGSPortalService
Parameters:
connectionID - ID of the connection, used to retrieve the PortalConnection. Must match the session connection ID, if the session connection ID exists
isBIC - Value to set all the samples to
projectID - DB Row ID of the project holding the samples
Returns:
True if assigned the value, else false
Throws:
ConnectionException - If the connectionID is not valid, or if it doesn't match the session connection ID

saveSecondaryDeliveryDate

public void saveSecondaryDeliveryDate(int connectID,
                                      int projectID,
                                      Date date)
                               throws ConnectionException
Saves the Secondary Delivery Date

Specified by:
saveSecondaryDeliveryDate in interface NGSPortalService
Parameters:
connectID - The id of the connection, so know what user has access to
Throws:
ConnectionException

saveSecondaryCompleteDate

public void saveSecondaryCompleteDate(int connectID,
                                      int projectID,
                                      Date date)
                               throws ConnectionException
Saves the secondary Complete Date. Fails if user is neither an administrator or a member of the PI Support staff

Specified by:
saveSecondaryCompleteDate in interface NGSPortalService
Throws:
ConnectionException

checkAccessPrivilages

public boolean checkAccessPrivilages(String userID)
Checks the user access

Specified by:
checkAccessPrivilages in interface NGSPortalService

saveSecondaryAssignedDate

public void saveSecondaryAssignedDate(int connectID,
                                      int projectID,
                                      Date newValue)
                               throws ConnectionException
Specified by:
saveSecondaryAssignedDate in interface NGSPortalService
Throws:
ConnectionException

addNewRerun

public String addNewRerun(int connectID,
                          int projectID,
                          String projectName)
                   throws ConnectionException
Specified by:
addNewRerun in interface NGSPortalService
Throws:
ConnectionException

writedatatofile

public void writedatatofile(int connectid,
                            String exportdata)
                     throws IOException
Specified by:
writedatatofile in interface NGSPortalService
Throws:
IOException

getSecondaryAnalysisHistory

public List<SecondaryDetails> getSecondaryAnalysisHistory(int connectid,
                                                          int projectid)
Specified by:
getSecondaryAnalysisHistory in interface NGSPortalService

getFlowcellsPerMonth

public Map<String,Integer> getFlowcellsPerMonth(SGEFilter filter,
                                                int connectID)
Specified by:
getFlowcellsPerMonth in interface NGSPortalService

savePersonneltoDB

public void savePersonneltoDB(int connectID,
                              int projectID,
                              String newISAssignee,
                              String oldISAssignee)
                       throws ConnectionException
Specified by:
savePersonneltoDB in interface NGSPortalService
Throws:
ConnectionException

saveSecondaryAnalysisNotes

public void saveSecondaryAnalysisNotes(int connectID,
                                       int analysisID,
                                       String notes)
                                throws ConnectionException
Replace the notes for a secondary analysis. Fails if user isn't a project admin or a member of IS staff

Specified by:
saveSecondaryAnalysisNotes in interface NGSPortalService
Parameters:
connectID - The id of the connection, so know what user has access to
analysisID - The analysis to replace the notes
notes - The new notes for the analysis
Throws:
ConnectionException - If not a valid connection

checkIfProjectNameIsUnique

public String checkIfProjectNameIsUnique(String projectName,
                                         Connection theConnection)
Checks if the Project Name entered by Admin already exists

Parameters:
projectName - The name of the project
theConnection - Connection to the DB to get the information
Returns:
Null if name does not exists else a potential name if project name already exists, or a warning if couldn't access the DB

getRunSecondaryAnalysisStatus

public boolean getRunSecondaryAnalysisStatus(List<Integer> sampleIDs)
Runs a SQL query to find if any of the Sequenced Samples in sampleIDs have a Secondary Analysis result of Delivered

Specified by:
getRunSecondaryAnalysisStatus in interface NGSPortalService
Parameters:
sampleIDs - List of IDs to look for, must not be empty or null
Returns:
True if any have been delivered, false otherwise

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws IOException,
                  javax.servlet.ServletException
Routine to produce the text displayed by this servlet when it is directly accessed by a web browser. Currently used to let us know the version of the servlet being accessed.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Throws:
IOException
javax.servlet.ServletException

sendWeeklyReport

public boolean sendWeeklyReport(String userlanID,
                                int connectionID)
                         throws ConnectionException
Generate an EMail Weekly Report

Specified by:
sendWeeklyReport in interface NGSPortalService
Parameters:
userlanID -
connectionID -
Returns:
True if sent the email successfully, false if there was a problem (non-Javadoc)
Throws:
ConnectionException
See Also:
NGSPortalService.sendWeeklyReport(java.lang.String, int)