Skip to content

Commit

Permalink
Merge pull request #95 from czbiohub-sf/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
InventoRyAlpaca authored Jan 24, 2024
2 parents 32ac6ea + abc3285 commit 7c9778b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/rapidqcms/AutoQCProcessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def sequence_is_valid(filename, contents, vendor="Thermo Fisher"):
Returns:
True if sequence table is valid, otherwise False.
"""

if ".csv" not in filename:
return False

Expand All @@ -44,15 +43,15 @@ def sequence_is_valid(filename, contents, vendor="Thermo Fisher"):

# Attempt to load sequence file as a pandas DataFrame
try:
#Remove the bracket_type header from the Xcalibur export/import
bracket_type = contents.readline()
log.debug("Sequence_is_valid bracket_type = {}".format(bracket_type))
df_sequence = pd.read_csv(contents, index_col=False)
except Exception as error:
print("Sequence file could not be read.")
traceback.print_exc()
return False

df_sequence.columns = df_sequence.iloc[0]
df_sequence = df_sequence.drop(df_sequence.index[0])

# Define required columns and columns found in sequence file
required_columns = ["File Name", "Path", "Instrument Method", "Position", "Inj Vol"]
sequence_file_columns = df_sequence.columns.tolist()
Expand Down Expand Up @@ -188,9 +187,10 @@ def convert_sequence_to_json(sequence_contents, vendor="Thermo Fisher"):

# Select columns from sequence using correct vendor software nomenclature
if vendor == "Thermo Fisher":
bracket_type = sequence_contents.readline()
log.debug("convert_sequence_to_json bracket_type is = {}".format(bracket_type))
df_sequence = pd.read_csv(sequence_contents, index_col=False)
df_sequence.columns = df_sequence.iloc[0]
df_sequence = df_sequence.drop(df_sequence.index[0])


# Convert DataFrames to JSON strings
return df_sequence.to_json(orient="split")
Expand Down
6 changes: 3 additions & 3 deletions src/rapidqcms/DatabaseFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1258,15 +1258,15 @@ def get_md5(instrument_id, sample_id):
engine = sa.create_engine(database)

# Check if sample is a biological standard
table = "sample_qc_results"
# can't parameterize tablenames
query = sa.text("SELECT * FROM sample_qc_results WHERE sample_id=:sample_id").bindparams(sample_id=sample_id)

for identifier in get_biological_standard_identifiers().keys():
if identifier in sample_id:
table = "bio_qc_results"
query = sa.text("SELECT * FROM bio_qc_results WHERE sample_id=:sample_id").bindparams(sample_id=sample_id)
break

# Get sample from correct table
query = sa.text("SELECT * FROM :table WHERE sample_id = :sample_id").bindparams(table=table, sample_id=sample_id)
df_sample_qc_results = pd.read_sql(query, engine)

return df_sample_qc_results["md5"].astype(str).values[0]
Expand Down

0 comments on commit 7c9778b

Please sign in to comment.