func LoadPRS(prsPath, layout string, alwaysIncrement bool) error {
	parser, err := prsparser.New(layout)
	if err != nil {
		return fmt.Errorf("CreatePRSParserErr: %s", err.Error())
	}

	// Open PRS file
	f, err := os.Open(prsPath)
	if err != nil {
		return pfx.Err(err)
	}
	defer f.Close()

	fd, err := genomisc.MaybeDecompressReadCloserFromFile(f)
	if err != nil {
		return pfx.Err(err)
	}
	defer fd.Close()

	reader := csv.NewReader(fd)
	reader.Comma = parser.CSVReaderSettings.Comma
	reader.Comment = parser.CSVReaderSettings.Comment
	reader.TrimLeadingSpace = parser.CSVReaderSettings.TrimLeadingSpace

	currentVariantScoreLookup = nil
	currentVariantScoreLookup = make(map[ChrPos]prsparser.PRS)
	for i := 0; ; i++ {
		row, err := reader.Read()
		if err != nil {
			if err == io.EOF {
				break
			} else if err, ok := err.(*csv.ParseError); ok && err.Err == csv.ErrFieldCount {
				// We actually permit this
				log.Printf("Recovering from parsing error which may be caused by jagged files with missing entries and proceeding with this variant. Error: %s", err.Error())
			} else {
				return pfx.Err(err)
			}
		}

		val, err := parser.ParseRow(row)
		if err != nil && i == 0 {
			// Permit a header and skip it
			continue
		} else if err != nil {
			return pfx.Err(err)
		}

		p := prsparser.PRS{
			Chromosome:   val.Chromosome,
			Position:     val.Position,
			EffectAllele: val.EffectAllele,
			Allele1:      val.Allele1,
			Allele2:      val.Allele2,
			Score:        val.Score,
			SNP:          val.SNP,
		}

		if p.EffectAllele != p.Allele1 && p.EffectAllele != p.Allele2 {
			return fmt.Errorf("Effect Allele (%v) is neither equal to Allele 1 (%v) nor Allele 2 (%v)", p.EffectAllele, p.Allele1, p.Allele2)
		}

		// Ensure that all scores will be positive. If the effect size is
		// negative, swap the effect and alt alleles and the effect sign.
		if alwaysIncrement && p.Score < 0 {
			p.Score *= -1
			if p.EffectAllele == p.Allele1 {
				p.EffectAllele = p.Allele2
			} else {
				p.EffectAllele = p.Allele1
			}
		}

		currentVariantScoreLookup[ChrPos{p.Chromosome, uint32(p.Position), p.SNP}] = p
	}

	return nil
}
// LoadPRS is ***not*** safe for concurrent access from multiple goroutines
LoadPRS is ***not*** safe for concurrent access from multiple goroutines
// LoadPRS is *** not *** safe for concurrent access from multiple goroutines
func LoadPRS(prsPath, layout string, alwaysIncrement bool) error {
	parser, err := prsparser.New(layout)
	if err != nil {
		return fmt.Errorf("CreatePRSParserErr: %s", err.Error())
	}
	f, err := os.Open(prsPath)
	if err != nil {
		return pfx.Err(err)
	}
	defer f.Close()
	fd, err := genomisc.MaybeDecompressReadCloserFromFile(f)
	if err != nil {
		return pfx.Err(err)
	}
	defer fd.Close()
	reader := csv.NewReader(fd)
	reader.Comma = parser.CSVReaderSettings.Comma
	reader.Comment = parser.CSVReaderSettings.Comment
	reader.TrimLeadingSpace = parser.CSVReaderSettings.TrimLeadingSpace
	currentVariantScoreLookup = nil
	currentVariantScoreLookup = make(map[ChrPos]prsparser.PRS)
	for i := 0; ; i++ {
		row, err := reader.Read()
		if err != nil {
			if err == io.EOF {
				break
			} else if err, ok := err.(*csv.ParseError); ok && err.Err == csv.ErrFieldCount {
				log.Printf("Recovering from parsing error which may be caused by jagged files with missing entries and proceeding with this variant. Error: %s", err.Error())
			} else {
				return pfx.Err(err)
			}
		}
		val, err := parser.ParseRow(row)
		if err != nil && i == 0 {
			continue
		} else if err != nil {
			return pfx.Err(err)
		}
		p := prsparser.PRS{
			Chromosome:   val.Chromosome,
			Position:     val.Position,
			EffectAllele: val.EffectAllele,
			Allele1:      val.Allele1,
			Allele2:      val.Allele2,
			Score:        val.Score,
			SNP:          val.SNP,
		}
		if p.EffectAllele != p.Allele1 && p.EffectAllele != p.Allele2 {
			return fmt.Errorf("Effect Allele (%v) is neither equal to Allele 1 (%v) nor Allele 2 (%v)", p.EffectAllele, p.Allele1, p.Allele2)
		}
		if alwaysIncrement && p.Score < 0 {
			p.Score *= -1
			if p.EffectAllele == p.Allele1 {
				p.EffectAllele = p.Allele2
			} else {
				p.EffectAllele = p.Allele1
			}
		}
		currentVariantScoreLookup[ChrPos{p.Chromosome, uint32(p.Position), p.SNP}] = p
	}
	return nil
}
func LoadPRS ( prsPath , layout string , alwaysIncrement bool ) error { parser , err := prsparser . New ( layout ) if err != nil { return fmt . Errorf ( " " , err . Error ( ) ) } f , err := os . Open ( prsPath ) if err != nil { return pfx . Err ( err ) } defer f . Close ( ) fd , err := genomisc . MaybeDecompressReadCloserFromFile ( f ) if err != nil { return pfx . Err ( err ) } defer fd . Close ( ) reader := csv . NewReader ( fd ) reader . Comma = parser . CSVReaderSettings . Comma reader . Comment = parser . CSVReaderSettings . Comment reader . TrimLeadingSpace = parser . CSVReaderSettings . TrimLeadingSpace currentVariantScoreLookup = nil currentVariantScoreLookup = make ( map [ ChrPos ] prsparser . PRS ) for i := 0 ; ; i ++ { row , err := reader . Read ( ) if err != nil { if err == io . EOF { break } else if err , ok := err . ( * csv . ParseError ) ; ok && err . Err == csv . ErrFieldCount { log . Printf ( " " , err . Error ( ) ) } else { return pfx . Err ( err ) } } val , err := parser . ParseRow ( row ) if err != nil && i == 0 { continue } else if err != nil { return pfx . Err ( err ) } p := prsparser . PRS { Chromosome : val . Chromosome , Position : val . Position , EffectAllele : val . EffectAllele , Allele1 : val . Allele1 , Allele2 : val . Allele2 , Score : val . Score , SNP : val . SNP , } if p . EffectAllele != p . Allele1 && p . EffectAllele != p . Allele2 { return fmt . Errorf ( " " , p . EffectAllele , p . Allele1 , p . Allele2 ) } if alwaysIncrement && p . Score < 0 { p . Score *= - 1 if p . EffectAllele == p . Allele1 { p . EffectAllele = p . Allele2 } else { p . EffectAllele = p . Allele1 } } currentVariantScoreLookup [ ChrPos { p . Chromosome , uint32 ( p . Position ) , p . SNP } ] = p } return nil }
LoadPRS is ***not*** safe for concurrent access from multiple goroutines
LoadPRS is *** not *** safe for concurrent access from multiple goroutines
// Open PRS file // We actually permit this // Permit a header and skip it // Ensure that all scores will be positive. If the effect size is // negative, swap the effect and alt alleles and the effect sign.