<commit_before>package org.opencb.biodata.models.variant;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.opencb.biodata.models.variant.stats.VariantStats;

/** 
 * File stored in an archive of variant information. It contains information 
 * related to samples, statistics and specifics of the file format.
 * 
 * @author <NAME> <<EMAIL>>
 */
public class ArchivedVariantFile {
    
    /**
     * Name of the archived file.
     */
    private String fileName;
    
    /**
     * Unique identifier of the archived file.
     */
    private String fileId;
    
    /**
     * Unique identifier of the study containing the archived file.
     */
    private String studyId;
    
    /**
     * Fields stored for each sample.
     */
    private String format;
    
    /**
     * Genotypes and other sample-related information. The keys are the names
     * of the samples. The values are pairs (field name, field value), such as
     * (GT, A/C).
     */
    private Map<String, Map<String, String>> samplesData;
    
    /**
     * Statistics of the genomic variation, such as its alleles/genotypes count 
     * or its minimum allele frequency.
     */
    private VariantStats stats;
    
    /**
     * Optional attributes that probably depend on the format of the file the
     * variant was initially read from.
     */
    private Map<String, String> attributes;

    ArchivedVariantFile() { }
    
    public ArchivedVariantFile(String fileName, String fileId, String studyId) {
        this.fileName = fileName;
        this.fileId = fileId;
        this.studyId = studyId;
        
        this.samplesData = new LinkedHashMap<>();
        this.attributes = new LinkedHashMap<>();
    }

    
    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public String getStudyId() {
        return studyId;
    }

    public void setStudyId(String studyId) {
        this.studyId = studyId;
    }

    public String getFormat() {
        return format;
    }

    public void setFormat(String format) {
        this.format = format;
    }

    public Map<String, Map<String, String>> getSamplesData() {
        return samplesData;
    }

    public String getSampleData(String sampleName, String field) {
        return this.samplesData.get(sampleName).get(field.toUpperCase());
    }

    public Map<String, String> getSampleData(String sampleName) {
        return samplesData.get(sampleName);
    }

    public void addSampleData(String sampleName, Map<String, String> sampleData) {
        this.samplesData.put(sampleName, sampleData);
    }

    public Set<String> getSampleNames() {
        return this.samplesData.keySet();
    }

    public VariantStats getStats() {
        return stats;
    }
<commit_msg>NullPointerExceptions when accessing to ArchivedVariantFile.samplesData removed<commit_after>package org.opencb.biodata.models.variant;

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.opencb.biodata.models.variant.stats.VariantStats;

/** 
 * File stored in an archive of variant information. It contains information 
 * related to samples, statistics and specifics of the file format.
 * 
 * @author <NAME> <<EMAIL>>
 */
public class ArchivedVariantFile {
    
    /**
     * Name of the archived file.
     */
    private String fileName;
    
    /**
     * Unique identifier of the archived file.
     */
    private String fileId;
    
    /**
     * Unique identifier of the study containing the archived file.
     */
    private String studyId;
    
    /**
     * Fields stored for each sample.
     */
    private String format;
    
    /**
     * Genotypes and other sample-related information. The keys are the names
     * of the samples. The values are pairs (field name, field value), such as
     * (GT, A/C).
     */
    private Map<String, Map<String, String>> samplesData;
    
    /**
     * Statistics of the genomic variation, such as its alleles/genotypes count 
     * or its minimum allele frequency.
     */
    private VariantStats stats;
    
    /**
     * Optional attributes that probably depend on the format of the file the
     * variant was initially read from.
     */
    private Map<String, String> attributes;

    ArchivedVariantFile() { 
        this(null, null, null);
    }
    
    public ArchivedVariantFile(String fileName, String fileId, String studyId) {
        this.fileName = fileName;
        this.fileId = fileId;
        this.studyId = studyId;
        
        this.samplesData = new LinkedHashMap<>();
        this.attributes = new LinkedHashMap<>();
    }

    
    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileId() {
        return fileId;
    }

    public void setFileId(String fileId) {
        this.fileId = fileId;
    }

    public String getStudyId() {
        return studyId;
    }

    public void setStudyId(String studyId) {
        this.studyId = studyId;
    }

    public String getFormat() {
        return format;
    }

    public void setFormat(String format) {
        this.format = format;
    }

    public Map<String, Map<String, String>> getSamplesData() {
        return samplesData;
    }

    public String getSampleData(String sampleName, String field) {
        Map<String, String> sampleData = samplesData.get(sampleName);
        if (sampleData == null) {
            return null;
        }
        return samplesData.get(sampleName).get(field.toUpperCase());
    }

    public Map<String, String> getSampleData(String sampleName) {
        return samplesData.get(sampleName);
    }

    public void addSampleData(String sampleName, Map<String, String> sampleData) {
        this.samplesData.put(sampleName, sampleData);
    }

    public Set<String> getSampleNames() {
        return this.samplesData.keySet();
    }

    public VariantStats getStats() {
        return stats;
    }

{'fraction_non_alphanumeric': 0.09149102263856362, 'fraction_numerical': 0.0, 'mean_word_length': 2.433011789924973, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6964055', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1759, 'n_words': 521}