In obimultiplex, patch a bug when no tag are associated to a primer.

This commit is contained in:
Eric Coissac
2024-10-22 14:12:20 +02:00
parent 9e8a7fd9be
commit 3e00d39d47
3 changed files with 36 additions and 1 deletions

View File

@ -536,6 +536,24 @@ var library_parameter = map[string]func(library *obingslibrary.NGSLibrary, value
},
}
// ReadCSVNGSFilter reads an NGS filter configuration from a CSV file and returns
// an NGSLibrary. The CSV file must include columns for 'experiment', 'sample',
// 'sample_tag', 'forward_primer', and 'reverse_primer'. Additional columns are
// used to annotate PCR samples.
//
// Parameters:
// - reader: an io.Reader providing the CSV input.
//
// Returns:
// - A pointer to an NGSLibrary populated with the data from the CSV file.
// - An error if the CSV is malformed or required columns are missing.
//
// The function processes both data records and parameter lines starting with
// '@param'. Parameter lines configure various aspects of the library.
//
// Each row in the CSV is validated to ensure it has the correct number of columns.
// Duplicate tag pairs for the same marker result in an error. Primer unicity is
// checked, and any unknown parameters are logged as warnings.
func ReadCSVNGSFilter(reader io.Reader) (*obingslibrary.NGSLibrary, error) {
ngsfilter := obingslibrary.MakeNGSLibrary()
file := csv.NewReader(reader)
@ -576,6 +594,7 @@ func ReadCSVNGSFilter(reader io.Reader) (*obingslibrary.NGSLibrary, error) {
extraColumns := make([]int, 0)
for i, colName := range header {
switch colName {
case "experiment":
experimentColIndex = i

View File

@ -343,6 +343,10 @@ func (marker *Marker) beginTagExtractor(
// log.Warnf("Forward : %v -> %d %c", forward, marker.Forward_spacer, marker.Forward_tag_delimiter)
// log.Warnf("Forward : %v -> %d %c", forward, marker.Reverse_spacer, marker.Reverse_tag_delimiter)
if forward {
if marker.Forward_tag_length == 0 {
return ""
}
if marker.Forward_tag_delimiter == 0 {
return marker.beginFixedTagExtractor(sequence, begin, forward)
} else {
@ -355,6 +359,10 @@ func (marker *Marker) beginTagExtractor(
}
}
} else {
if marker.Reverse_tag_length == 0 {
return ""
}
if marker.Reverse_tag_delimiter == 0 {
return marker.beginFixedTagExtractor(sequence, begin, forward)
} else {
@ -374,6 +382,10 @@ func (marker *Marker) endTagExtractor(
end int,
forward bool) string {
if forward {
if marker.Reverse_tag_length == 0 {
return ""
}
if marker.Reverse_tag_delimiter == 0 {
return marker.endFixedTagExtractor(sequence, end, forward)
} else {
@ -386,6 +398,10 @@ func (marker *Marker) endTagExtractor(
}
}
} else {
if marker.Forward_tag_length == 0 {
return ""
}
if marker.Forward_tag_delimiter == 0 {
return marker.endFixedTagExtractor(sequence, end, forward)
} else {

View File

@ -7,7 +7,7 @@ import (
// TODO: The version number is extracted from git. This induces that the version
// corresponds to the last commit, and not the one when the file will be
// commited
var _Commit = "74280e4"
var _Commit = "9e8a7fd"
var _Version = "Release 4.2.0"
// Version returns the version of the obitools package.