src/main/java/org/ncgr/gwas/PhenoSubjects.java
void loadSampleIdMap() throws FileNotFoundException, IOException {
	BufferedReader sampleReader = new BufferedReader(new FileReader(samplefilename));
	int sampleVarOffset = -1;
	boolean headerLine = true;
	String line = null;
	while ((line=sampleReader.readLine())!=null) {
	    if (line.startsWith("#")) {
		continue; // comment
	    } else if (line.trim().length()==0) {
		continue; // blank
	    } else if (headerLine) {
		// variable header
		String[] vars = line.split("\t");
		for (int i=0; i<vars.length; i++) {
		    if (vars[i].equals(sampleVar)) sampleVarOffset = i;
		}
		headerLine = false;
	    } else {
		String[] data = line.split("\t");
		String dbGaPSubjectId = data[0]; // assume first column is dbGaP_Subject_ID, which I hope is always true -- not necessarily unique!!
		String sampleId = data[sampleVarOffset]; // presume this is unique
		sampleIdMap.put(sampleId, dbGaPSubjectId);
	    }
	}
	sampleReader.close();
    }
/**
     * The optional sample file relates dbGaP_Subject_ID in the phenotypes file to the sample ID.
     *
     * dbGaP_Subject_ID dbGaP_Sample_ID	BioSample Accession  SUBJID	SAMPID	SAMP_SOURCE SOURCE_SAMPID SAMPLE_USE
     * 1284423	    1836728	        SAMN03897975	     PT-1S8D	28278	KAROLINSKA  28278	  Seq_DNA_WholeExome; Seq_DNA_SNP_CNV
     *
     * phs001949.v1.pht009705.v1.p1.P3DT_Sample.MULTI.txt
     * dbGaP_Subject_ID  dbGaP_Sample_ID  BioSample Accession  SUBJECT_ID  SAMPLE_ID
     * 3110589           3768892          SAMN13583397         1           42
     *
     * NOTE: there may be MORE THAN ONE LINE for the same dbGaP_Subject_ID! We'll assume that SAMPLE IDs are unique.
     */
The optional sample file relates dbGaP_Subject_ID in the phenotypes file to the sample ID.




The optional sample file relates dbGaP_Subject_ID in the phenotypes file to the sample ID .
void loadSampleIdMap() throws FileNotFoundException, IOException {
	BufferedReader sampleReader = new BufferedReader(new FileReader(samplefilename));
	int sampleVarOffset = -1;
	boolean headerLine = true;
	String line = null;
	while ((line=sampleReader.readLine())!=null) {
	    if (line.startsWith("#")) {
		continue; 
	    } else if (line.trim().length()==0) {
		continue; 
	    } else if (headerLine) {
		String[] vars = line.split("\t");
		for (int i=0; i<vars.length; i++) {
		    if (vars[i].equals(sampleVar)) sampleVarOffset = i;
		}
		headerLine = false;
	    } else {
		String[] data = line.split("\t");
		String dbGaPSubjectId = data[0]; 
		String sampleId = data[sampleVarOffset]; 
		sampleIdMap.put(sampleId, dbGaPSubjectId);
	    }
	}
	sampleReader.close();
    }
void loadSampleIdMap ( ) throws FileNotFoundException , IOException { BufferedReader sampleReader = new BufferedReader ( new FileReader ( samplefilename ) ) ; int sampleVarOffset = - 1 ; boolean headerLine = true ; String line = null ; while ( ( line = sampleReader . readLine ( ) ) != null ) { if ( line . startsWith ( "#" ) ) { continue ; } else if ( line . trim ( ) . length ( ) == 0 ) { continue ; } else if ( headerLine ) { String [ ] vars = line . split ( "\t" ) ; for ( int i = 0 ; i < vars . length ; i ++ ) { if ( vars [ i ] . equals ( sampleVar ) ) sampleVarOffset = i ; } headerLine = false ; } else { String [ ] data = line . split ( "\t" ) ; String dbGaPSubjectId = data [ 0 ] ; String sampleId = data [ sampleVarOffset ] ; sampleIdMap . put ( sampleId , dbGaPSubjectId ) ; } } sampleReader . close ( ) ; }
The optional sample file relates dbGaP_Subject_ID in the phenotypes file to the sample ID.
The optional sample file relates dbGaP_Subject_ID in the phenotypes file to the sample ID .
// comment // blank // variable header // assume first column is dbGaP_Subject_ID, which I hope is always true -- not necessarily unique!! // presume this is unique