Add automatic garbage collection on ApatPattern

This commit is contained in:
2022-01-24 17:26:30 +01:00
parent 703eb62819
commit 251d3be923
10 changed files with 119 additions and 92 deletions

View File

@@ -28,21 +28,21 @@ func OptionSet(options *getoptions.GetOpt) {
// Returns true if the number of reads described in the
// file has to be printed.
func IsPrintingReadCount() bool {
func CLIIsPrintingReadCount() bool {
return __read_count__ ||
!(__read_count__ || __variant_count__ || __symbol_count__)
}
// Returns true if the number of sequence variants described in the
// file has to be printed.
func IsPrintingVariantCount() bool {
func CLIIsPrintingVariantCount() bool {
return __variant_count__ ||
!(__read_count__ || __variant_count__ || __symbol_count__)
}
// Returns true if the number of symbols (sum of the sequence lengths)
// described in the file has to be printed.
func IsPrintingSymbolCount() bool {
func CLIIsPrintingSymbolCount() bool {
return __symbol_count__ ||
!(__read_count__ || __variant_count__ || __symbol_count__)
}

View File

@@ -22,7 +22,7 @@ func IFilterRankRestriction() func(*obitax.ITaxonSet) *obitax.ITaxonSet {
}
func ITaxonNameMatcher() (func(string) *obitax.ITaxonSet, error) {
taxonomy, err := LoadSelectedTaxonomy()
taxonomy, err := CLILoadSelectedTaxonomy()
if err != nil {
return nil, err
@@ -37,7 +37,7 @@ func ITaxonNameMatcher() (func(string) *obitax.ITaxonSet, error) {
func ITaxonRestrictions() (func(*obitax.ITaxonSet) *obitax.ITaxonSet, error) {
clades, err := TaxonomicalRestrictions()
clades, err := CLITaxonomicalRestrictions()
if err != nil {
return nil, err

View File

@@ -44,16 +44,16 @@ func LoadTaxonomyOptionSet(options *getoptions.GetOpt, required, alternatiive bo
options.Description("Restrict output to some subclades."))
}
func SelectedNCBITaxDump() string {
func CLISelectedNCBITaxDump() string {
return __taxdump__
}
func AreAlternativeNamesSelected() bool {
func CLIAreAlternativeNamesSelected() bool {
return __alternative_name__
}
func TaxonomicalRestrictions() (*obitax.TaxonSet, error) {
taxonomy, err := LoadSelectedTaxonomy()
func CLITaxonomicalRestrictions() (*obitax.TaxonSet, error) {
taxonomy, err := CLILoadSelectedTaxonomy()
if err != nil {
return nil, err
@@ -73,12 +73,12 @@ func TaxonomicalRestrictions() (*obitax.TaxonSet, error) {
return &ts, nil
}
func LoadSelectedTaxonomy() (*obitax.Taxonomy, error) {
if SelectedNCBITaxDump() != "" {
func CLILoadSelectedTaxonomy() (*obitax.Taxonomy, error) {
if CLISelectedNCBITaxDump() != "" {
if __selected_taxonomy__ == nil {
var err error
__selected_taxonomy__, err = ncbitaxdump.LoadNCBITaxDump(SelectedNCBITaxDump(),
!AreAlternativeNamesSelected())
__selected_taxonomy__, err = ncbitaxdump.LoadNCBITaxDump(CLISelectedNCBITaxDump(),
!CLIAreAlternativeNamesSelected())
if err != nil {
return nil, err
}
@@ -105,10 +105,10 @@ func OptionSet(options *getoptions.GetOpt) {
options.Description("Restrict to the given taxonomic rank."))
}
func RequestsPathForTaxid() int {
func CLIRequestsPathForTaxid() int {
return __taxid_path__
}
func RequestsSonsForTaxid() int {
func CLIRequestsSonsForTaxid() int {
return __taxid_sons__
}

View File

@@ -12,6 +12,7 @@ var _Delta = 5
var _MinOverlap = 20
var _GapPenality = float64(2.0)
var _WithoutStats = false
var _MinIdentity = 0.9
func PairingOptionSet(options *getoptions.GetOpt) {
options.StringSliceVar(&_ForwardFiles, "forward-reads",
@@ -22,16 +23,19 @@ func PairingOptionSet(options *getoptions.GetOpt) {
1, 1000,
options.Alias("R"),
options.Description("The file names containing the reverse reads"))
options.IntVar(&_Delta, "delta", 5,
options.IntVar(&_Delta, "delta", _Delta,
options.Alias("D"),
options.Description("Length added to the fast detected overlap for the precise alignement (default 5)."))
options.IntVar(&_MinOverlap, "min-overlap", 20,
options.Description("Length added to the fast detected overlap for the precise alignement"))
options.IntVar(&_MinOverlap, "min-overlap", _MinOverlap,
options.Alias("O"),
options.Description("Minimum ovelap between both the reads to consider the aligment (default 20)."))
options.Float64Var(&_GapPenality, "gap-penality", 2,
options.Description("Minimum ovelap between both the reads to consider the aligment"))
options.Float64Var(&_MinIdentity, "min-identity", _MinIdentity,
options.Alias("O"),
options.Description("Minimum identity between ovelaped regions of the reads to consider the aligment"))
options.Float64Var(&_GapPenality, "gap-penality", _GapPenality,
options.Alias("G"),
options.Description("Gap penality expressed as the multiply factor applied to the mismatch score between two nucleotides with a quality of 40 (default 2)."))
options.BoolVar(&_WithoutStats, "without-stat", false,
options.BoolVar(&_WithoutStats, "without-stat", _WithoutStats,
options.Alias("S"),
options.Description("Remove alignment statistics from the produced consensus sequences."))
}
@@ -65,6 +69,10 @@ func MinOverlap() int {
return _MinOverlap
}
func MinIdentity() float64 {
return _MinIdentity
}
func GapPenality() float64 {
return _GapPenality
}

View File

@@ -105,7 +105,7 @@ func JoinPairedSequence(seqA, seqB obiseq.BioSequence, inplace bool) obiseq.BioS
// input sequence.
//
func AssemblePESequences(seqA, seqB obiseq.BioSequence,
gap float64, delta, overlapMin int, withStats bool,
gap float64, delta, minOverlap int, minIdentity float64,withStats bool,
inplace bool,
arenaAlign obialign.PEAlignArena) obiseq.BioSequence {
@@ -119,8 +119,9 @@ func AssemblePESequences(seqA, seqB obiseq.BioSequence,
}
lcons := cons.Length()
aliLength := lcons - _Abs(left) - _Abs(right)
identity := float64(match)/float64(aliLength)
if aliLength >= overlapMin {
if aliLength >= minOverlap && identity >= minIdentity {
if withStats {
annot := cons.Annotations()
annot["mode"] = "alignment"
@@ -203,7 +204,7 @@ func AssemblePESequences(seqA, seqB obiseq.BioSequence,
// each pair of processed sequences produces one sequence in the result iterator.
//
func IAssemblePESequencesBatch(iterator obiseq.IPairedBioSequenceBatch,
gap float64, delta, minOverlap int, withStats bool, sizes ...int) obiseq.IBioSequenceBatch {
gap float64, delta, minOverlap int, minIdentity float64, withStats bool, sizes ...int) obiseq.IBioSequenceBatch {
nworkers := runtime.NumCPU() * 3 / 2
buffsize := iterator.BufferSize()
@@ -246,7 +247,7 @@ func IAssemblePESequencesBatch(iterator obiseq.IPairedBioSequenceBatch,
processed := 0
for i, A := range batch.Forward() {
B := batch.Reverse()[i]
cons[i] = AssemblePESequences(A, B, gap, delta, minOverlap, withStats, true, arena)
cons[i] = AssemblePESequences(A, B, gap, delta, minOverlap, minIdentity, withStats, true, arena)
if i%59 == 0 {
bar.Add(59)
processed += 59