Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/master' into improve_NGS…
Browse files Browse the repository at this point in the history
…DExportSV
  • Loading branch information
Kilian Ilius committed Jan 15, 2025
2 parents 4e4a6d7 + 38b6200 commit b03359d
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/GSvarServer-TEST/Controller-Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,6 @@ private slots:

// This test is intended to be changed when PathType changes, OTHER is always the last element,
// it will always change when items are added or deleted
I_EQUAL(static_cast<int>(PathType::OTHER), 45);
I_EQUAL(static_cast<int>(PathType::OTHER), 47);
}
};
18 changes: 15 additions & 3 deletions src/GSvarServer/ServerController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,19 @@ HttpResponse ServerController::locateFileByType(const HttpRequest& request)
case PathType::CFDNA_CANDIDATES:
file_list << file_locator->getSomaticCfdnaCandidateFile();
break;
case PathType::GSVAR:
file_list << FileLocation(url_entity.file_id, PathType::GSVAR, found_file, true);
break;
case PathType::METHYLATION:
file_list << file_locator->getMethylationFile();
break;
case PathType::METHYLATION_IMAGE:
if (locus.isEmpty())
{
return HttpResponse(ResponseStatus::BAD_REQUEST, HttpUtils::detectErrorContentType(request.getHeaderByName("User-Agent")), EndpointManager::formatResponseMessage(request, "Locus value has not been provided"));
}
file_list << file_locator->getMethylationImage(locus);
break;
case PathType::GSVAR:
file_list << FileLocation(url_entity.file_id, PathType::GSVAR, found_file, true);
break;
case PathType::SAMPLE_FOLDER:
case PathType::FUSIONS_PIC_DIR:
case PathType::FUSIONS:
Expand All @@ -467,8 +477,10 @@ HttpResponse ServerController::locateFileByType(const HttpRequest& request)
}
}


for (int i = 0; i < file_list.count(); ++i)
{
Log::info("file path: " + file_list.at(i).filename);
QJsonObject cur_json_item;
QJsonObject cur_json_item_without_token;
cur_json_item.insert("id", file_list[i].id);
Expand Down
13 changes: 13 additions & 0 deletions src/cppNGSD/FileLocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ enum class PathType
BAM, //BAM file
VIRAL_BAM, //BAM file for a virus
CRAM, //compressed version of BAM

//variant data
VCF, //small variants (VCF.GZ format)
GSVAR, //small variants (GSvar format)
Expand Down Expand Up @@ -60,6 +61,8 @@ enum class PathType
SIGNATURE_ID, // Somatic: resut part from SigProfileExtractor for SNVs (CSV format)
SIGNATURE_DBS, // Somatic: resut part from SigProfileExtractor for SNVs (CSV format)
SIGNATURE_CNV, // Somatic: resut from SigProfileExtractor for CNVs (CSV format)
METHYLATION, // Methylation calls (TSV format)
METHYLATION_IMAGE, // image of a given methylation locus (PNG format)
OTHER // everything else
};

Expand Down Expand Up @@ -212,6 +215,10 @@ struct FileLocation
return "SIGNATURE_DBS";
case PathType::SIGNATURE_CNV:
return "SIGNATURE_CNV";
case PathType::METHYLATION:
return "METHYLATION";
case PathType::METHYLATION_IMAGE:
return "METHYLATION_IMAGE";

}
THROW(ProgrammingException, "Unhandled path type '" + QString::number((int)pathtype) + "' in typeToString()!");
Expand Down Expand Up @@ -267,6 +274,8 @@ struct FileLocation
if (in_upper == "SIGNATURE_ID") return PathType::SIGNATURE_ID;
if (in_upper == "SIGNATURE_DBS") return PathType::SIGNATURE_DBS;
if (in_upper == "SIGNATURE_CNV") return PathType::SIGNATURE_CNV;
if (in_upper == "METHYLATION") return PathType::METHYLATION;
if (in_upper == "METHYLATION_IMAGE") return PathType::METHYLATION_IMAGE;
THROW(ProgrammingException, "Unhandled path type string '" + in_upper + "' in stringToType()!");
}

Expand Down Expand Up @@ -366,6 +375,10 @@ struct FileLocation
return "DBS signature";
case PathType::SIGNATURE_CNV:
return "CNV signature";
case PathType::METHYLATION:
return "methylation calls";
case PathType::METHYLATION_IMAGE:
return "image of a given methylation locus";
}
THROW(ProgrammingException, "Unhandled path type '" + QString::number((int)pathtype) + "' in typeToHumanReadableString()!");
}
Expand Down
4 changes: 4 additions & 0 deletions src/cppNGSD/FileLocationProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class CPPNGSDSHARED_EXPORT FileLocationProvider
virtual FileLocation getRepeatExpansionHistogram(QString locus) const = 0;
//Returns sample-specific qcML files.
virtual FileLocationList getQcFiles() const = 0;
//Returns the methylation TSV file of the current analysis
virtual FileLocation getMethylationFile() const = 0;
//Returns the methylation image of a given locus
virtual FileLocation getMethylationImage(QString locus) const = 0;

//############################## sample-specific files ##############################
//Returns sample-specific BAM files
Expand Down
16 changes: 16 additions & 0 deletions src/cppNGSD/FileLocationProviderLocal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ FileLocationList FileLocationProviderLocal::getQcFiles() const
return output;
}

FileLocation FileLocationProviderLocal::getMethylationFile() const
{
QString name = QFileInfo(gsvar_file_).baseName();
QString file = gsvar_file_.left(gsvar_file_.length()-6) + "_var_methylation.tsv";

return FileLocation{name, PathType::METHYLATION, file, QFile::exists(file)};
}

FileLocation FileLocationProviderLocal::getMethylationImage(QString locus) const
{
QString name = QFileInfo(gsvar_file_).baseName();
QString file = getAnalysisPath() + QDir::separator() + "methylartist" + QDir::separator() + name + "_" + locus + ".png";

return FileLocation(name, PathType::METHYLATION_IMAGE, file, QFile::exists(file));
}

void FileLocationProviderLocal::addToList(const FileLocation& loc, FileLocationList& list, bool add_if_missing)
{
bool exists = QFile::exists(loc.filename);
Expand Down
2 changes: 2 additions & 0 deletions src/cppNGSD/FileLocationProviderLocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class CPPNGSDSHARED_EXPORT FileLocationProviderLocal
FileLocation getRepeatExpansionImage(QString locus) const override;
FileLocation getRepeatExpansionHistogram(QString locus) const override;
FileLocationList getQcFiles() const override;
FileLocation getMethylationFile() const override;
FileLocation getMethylationImage(QString locus) const override;

FileLocationList getVcfFiles(bool return_if_missing) const override;
FileLocationList getBamFiles(bool return_if_missing) const override;
Expand Down
10 changes: 10 additions & 0 deletions src/cppNGSD/FileLocationProviderRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ FileLocationList FileLocationProviderRemote::getQcFiles() const
return getFileLocationsByType(PathType::QC, false);
}

FileLocation FileLocationProviderRemote::getMethylationFile() const
{
return getOneFileLocationByType(PathType::METHYLATION, "");
}

FileLocation FileLocationProviderRemote::getMethylationImage(QString locus) const
{
return getOneFileLocationByType(PathType::METHYLATION_IMAGE, locus);
}

FileLocationList FileLocationProviderRemote::getFileLocationsByType(PathType type, bool return_if_missing) const
{
FileLocationList output;
Expand Down
2 changes: 2 additions & 0 deletions src/cppNGSD/FileLocationProviderRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class CPPNGSDSHARED_EXPORT FileLocationProviderRemote
FileLocation getRepeatExpansionImage(QString locus) const override;
FileLocation getRepeatExpansionHistogram(QString locus) const override;
FileLocationList getQcFiles() const override;
FileLocation getMethylationFile() const override;
FileLocation getMethylationImage(QString locus) const override;

FileLocationList getBamFiles(bool return_if_missing) const override;
FileLocationList getViralBamFiles(bool return_if_missing) const override;
Expand Down
1 change: 1 addition & 0 deletions src/cppNGSD/NGSD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,7 @@ QString NGSD::processedSamplePath(const QString& processed_sample_id, PathType t
output += ps_name + "_repeats.vcf";
}
}
else if (type==PathType::METHYLATION) output += ps_name + "_var_methylation.tsv";
else if (type!=PathType::SAMPLE_FOLDER) THROW(ProgrammingException, "Unhandled PathType '" + FileLocation::typeToString(type) + "' in processedSamplePath!");

return QFileInfo(output).absoluteFilePath();
Expand Down

0 comments on commit b03359d

Please sign in to comment.