sanger / limber

A config-driven LIMS built on Sequencescape, primarily for running library preparation pipelines in the laboratory
MIT License
4 stars 8 forks source link

Y24-027 [BUG] Create child LTN Al Lib Dil plate from LTN Al Lib plate for targeted nanoseq in Production (data fix) #1627

Closed andrewsparkes closed 8 months ago

andrewsparkes commented 8 months ago

Describe the bug As Sara W we have an LTN Al Lib plate for Targeted NanoSeq that cannot progress due to an error with the file upload. We would like an LTN AL Lib Dil child plate created from that LTN Al Lib plate so we can progress.

RT Ticket Number NA

To Reproduce Steps to reproduce the behaviour:

  1. Go to the LTN Al Lib plate and click the button to create the child LTN Al Lib Dil plate
  2. Upload a file with unusual characters in the hyb panel column
  3. See a 500 server error with a background exception email for 'malformed UTF-8'
  4. Note that child plate has been created anyway but binning is incorrectly done (user cancels it)
  5. Note that partial poly-metadata for the requests for the plate has been created
  6. Note that further attempts at creating LTN Al Lib Dil plates now fail as metadata with the same keys already exists for the requests in those wells (code only allows inserts of fresh keys and fails with duplicate errors)

Expected behaviour In this case we would have liked the file parsing to pick up the unusual characters in the file and reported that to the user at file upload before a child plate is made. We would have liked the error the user saw to be informative rather than a generic 500 error. We would like to be able to create more than one child plate from the LTN Al Lib plate but cannot.

Screenshots NA

Additional context This ticket is to fix the immediate problem with the data to allow this plate to continue and unblock the users.

We will not fix any code in this story.

See original plate file (attached) with the unusual hyphen character in the hyb panel column of the last 8 wells (text is Twist exome - humgen).

SQPP-47490-J_AL Lib Dilution volumes_120324.csv

andrewsparkes commented 8 months ago

How this data issue was fixed

Testing locally by running the integration suite to the AL Lib plate and using the file above and breakpoints in the code we identified the character that was causing the problem.

Created a new version of that file without the dodgy character.

Second problem is the code doesn't currently cope with creating the same metadata keys more than once on the same requests, so you cannot make a second child from the AL Lib plate. So we deleted the existing metadata on those requests. Then we can create a new child LTN Al Lib Dil plate in Limber, uploading the fixed file.

Steps:

SQL queries to identify and delete the metadata (replace submission_id with correct submission id for the targeted nanoseq library prep submission for the LTN AL Lib plate):

SELECT pm.*
FROM poly_metadata pm, submissions s
JOIN requests r ON r.submission_id = s.id
WHERE pm.metadatable_id = r.id
AND s.id = **submission_id**
;

DELETE 
FROM poly_metadata
WHERE poly_metadata.metadatable_id IN(
  SELECT r.id
    FROM submissions s
    JOIN requests r ON r.submission_id = s.id
    WHERE s.id =  **submission_id**
);
andrewsparkes commented 8 months ago

NB. They will still NOT be able to make additional LTN Al Lib Dil plates from the same AL Lib plate without a fix to the code that creates the metadata records, to allow for updates.

NB. This does NOT prevent further attempts to upload unusual characters in customer files.

andrewsparkes commented 8 months ago

Also, you can find the existing metadata by searching on the poly_metadata table for key 'original_plate_barcode' with value of the LTN AL Lib barcode to get all the metadatable ids that you need to remove (9 rows per metadatable id).