mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 08:40:26 +00:00
Change the way sequence definition are managed. They are now when present stored as an attribute
Former-commit-id: 6e618377c05b42937d2eace3c9668390980ab68c
This commit is contained in:
9
pkg/obiformats/empty_file.go
Normal file
9
pkg/obiformats/empty_file.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package obiformats
|
||||
|
||||
import "git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||
|
||||
func ReadEmptyFile(options ...WithOption) (obiiter.IBioSequence, error) {
|
||||
out := obiiter.MakeIBioSequence()
|
||||
out.Close()
|
||||
return out, nil
|
||||
}
|
||||
@@ -294,6 +294,11 @@ func ReadFastaFromFile(filename string, options ...WithOption) (obiiter.IBioSequ
|
||||
|
||||
file, err := Ropen(filename)
|
||||
|
||||
if err == ErrNoContent {
|
||||
log.Infof("file %s is empty", filename)
|
||||
return ReadEmptyFile(options...)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return obiiter.NilIBioSequence, err
|
||||
}
|
||||
@@ -305,6 +310,11 @@ func ReadFastaFromStdin(reader io.Reader, options ...WithOption) (obiiter.IBioSe
|
||||
options = append(options, OptionsSource(obiutils.RemoveAllExt("stdin")))
|
||||
input, err := Buf(os.Stdin)
|
||||
|
||||
if err == ErrNoContent {
|
||||
log.Infof("stdin is empty")
|
||||
return ReadEmptyFile(options...)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("open file error: %v", err)
|
||||
return obiiter.NilIBioSequence, err
|
||||
|
||||
@@ -339,6 +339,11 @@ func ReadFastqFromFile(filename string, options ...WithOption) (obiiter.IBioSequ
|
||||
|
||||
file, err := Ropen(filename)
|
||||
|
||||
if err == ErrNoContent {
|
||||
log.Infof("file %s is empty", filename)
|
||||
return ReadEmptyFile(options...)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return obiiter.NilIBioSequence, err
|
||||
}
|
||||
@@ -350,6 +355,11 @@ func ReadFastqFromStdin(reader io.Reader, options ...WithOption) (obiiter.IBioSe
|
||||
options = append(options, OptionsSource(obiutils.RemoveAllExt("stdin")))
|
||||
input, err := Buf(os.Stdin)
|
||||
|
||||
if err == ErrNoContent {
|
||||
log.Infof("stdin is empty")
|
||||
return ReadEmptyFile(options...)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("open file error: %v", err)
|
||||
return obiiter.NilIBioSequence, err
|
||||
|
||||
@@ -59,9 +59,13 @@ func _parseMainNGSFilterTags(text string) obingslibrary.TagPair {
|
||||
}
|
||||
}
|
||||
|
||||
func _parseMainNGSFilter(text string) (obingslibrary.PrimerPair, obingslibrary.TagPair, string, string, bool) {
|
||||
func _parseMainNGSFilter(text string) (obingslibrary.PrimerPair, obingslibrary.TagPair, string, string, bool, bool) {
|
||||
fields := strings.Fields(text)
|
||||
|
||||
if len(fields) < 6 {
|
||||
return obingslibrary.PrimerPair{}, obingslibrary.TagPair{}, "", "", false, false
|
||||
}
|
||||
|
||||
tags := _parseMainNGSFilterTags(fields[2])
|
||||
partial := fields[5] == "T" || fields[5] == "t"
|
||||
|
||||
@@ -72,7 +76,8 @@ func _parseMainNGSFilter(text string) (obingslibrary.PrimerPair, obingslibrary.T
|
||||
tags,
|
||||
fields[0],
|
||||
fields[1],
|
||||
partial
|
||||
partial,
|
||||
true
|
||||
}
|
||||
|
||||
func ReadNGSFilter(reader io.Reader) (obingslibrary.NGSLibrary, error) {
|
||||
@@ -89,7 +94,15 @@ func ReadNGSFilter(reader io.Reader) (obingslibrary.NGSLibrary, error) {
|
||||
|
||||
split := strings.SplitN(line, "@", 2)
|
||||
|
||||
primers, tags, experiment, sample, partial := _parseMainNGSFilter(split[0])
|
||||
if len(split) < 1 {
|
||||
return nil, fmt.Errorf("line %d : invalid format", i+1)
|
||||
}
|
||||
|
||||
primers, tags, experiment, sample, partial, ok := _parseMainNGSFilter(split[0])
|
||||
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("line %d : invalid format", i+1)
|
||||
}
|
||||
|
||||
marker, _ := ngsfilter.GetMarker(primers.Forward, primers.Reverse)
|
||||
pcr, ok := marker.GetPCR(tags.Forward, tags.Reverse)
|
||||
|
||||
Reference in New Issue
Block a user