<commit_before>/**
 * Helper utility that walks the user through turning a sample info source / file
 * into a PED file with family relationships.
 * 
 * @author <EMAIL>
 */

import static RelationshipType.*

class SamplesToPed {

    public SamplesToPed() {
    }
    
    static void main(String [] args) {
		
        if(!args) {
            System.err.println "Please provide sample info file to process\n"
            System.exit(1)
        }
            
        Map<String,SampleInfo> infos = SampleInfo.parse_sample_info(args[0])
        
        List<String> samples = infos.keySet() as List
        
        Map<String,Pedigree> pedigrees = [:]
	        
		while(samples) {
	        infos.each { String sample, SampleInfo info ->
	            println sample.padRight(20) + " : " + info.sex
	        }
	        
	        // Find the longest common substring
	        Reader r = System.in.newReader()
	        def group = lcs(samples)
	        
	        
	        Map<String, Subject> subjects = [:]
	        
	        Map<String,Relationship> rels = [:]
	        
	        group.members.each { sample ->
	            println "Pedigree for $sample [$group.group]: "
	            String pedigree = r.readLine()
	            if(pedigree.isEmpty())
	                pedigree = group.group
	                
	                
	            String sex = infos[sample].sex.name()
	            if(infos[sample].sex == Sex.UNKNOWN) {
	                println "Sex for sample $sample [${infos[sample].sex.name()}]:"
	                sex = r.readLine()
	                if(sex.isEmpty()) {
	                    sex = infos[sample].sex.name()
	                }
	            }
	                    
	            String rel 
	            String relDefault = defaultRelationship(sample)
	            while(!["m","f","c","s"].contains(rel)) {
	                println "Relationship for $sample [m/f/c/s] ($relDefault): "
	                String relValue = r.readLine()
	                if(relValue)
	                    rel = relValue
	                else
	                    rel = relDefault
	            }
	            
	            String phenotypeValue
	            int phenotype = rel == "c" ? 1 : 0
	            while(!["a","u"].contains(phenotypeValue)) {
	                println "Phenotype for $sample [a/u] ($phenotype): "
	                phenotypeValue = r.readLine()<commit_msg>trim trailing underscore from pedigree name<commit_after>/**
 * Helper utility that walks the user through turning a sample info source / file
 * into a PED file with family relationships.
 * 
 * @author <EMAIL>
 */

import static RelationshipType.*

class SamplesToPed {

    public SamplesToPed() {
    }
    
    static void main(String [] args) {
		
        if(!args) {
            System.err.println "Please provide sample info file to process\n"
            System.exit(1)
        }
            
        Map<String,SampleInfo> infos = SampleInfo.parse_sample_info(args[0])
        
        List<String> samples = infos.keySet() as List
        
        Map<String,Pedigree> pedigrees = [:]
	        
		while(samples) {
	        infos.each { String sample, SampleInfo info ->
	            println sample.padRight(20) + " : " + info.sex
	        }
	        
	        // Find the longest common substring
	        Reader r = System.in.newReader()
	        def group = lcs(samples)
	        
	        
	        Map<String, Subject> subjects = [:]
	        
	        Map<String,Relationship> rels = [:]
	        
	        group.members.each { sample ->
                
                String pedigree = group.group.replaceAll('_$','')
                
	            println "Pedigree for $sample [$pedigree]: "
	            String pedigreeValue = r.readLine()
	            if(!pedigree.isEmpty())
	                pedigree = pedigreeValue
	                
	                
	            String sex = infos[sample].sex.name()
	            if(infos[sample].sex == Sex.UNKNOWN) {
	                println "Sex for sample $sample [${infos[sample].sex.name()}]:"
	                sex = r.readLine()
	                if(sex.isEmpty()) {
	                    sex = infos[sample].sex.name()
	                }
	            }
	                    
	            String rel 
	            String relDefault = defaultRelationship(sample)
	            while(!["m","f","c","s"].contains(rel)) {
	                println "Relationship for $sample [m/f/c/s] ($relDefault): "
	                String relValue = r.readLine()
	                if(relValue)
	                    rel = relValue
	                else
	                    rel = relDefault
	            }
	            
	            String phenotypeValue
	            int phenotype = rel == "c" ? 1 : 0
	            while(!["a","u"].contains(phenotypeValue)) {
	                println "Phenotype for $sample [a/u] ($phenotype): "
	                phenotypeValue = r.readLine()
{'fraction_non_alphanumeric': 0.10764525993883792, 'fraction_numerical': 0.0024464831804281344, 'mean_word_length': 1.354126679462572, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1991512', 'n_tokens_mistral': 1440, 'n_tokens_neox': 1253, 'n_words': 299}