Get start and end coordinates per chromosome I will use GATK for SNP calling (HaplotypeCaller). I need to feed the interval file in the command, otherwise I get errors (even though I want to use the whole genome, not a subset  - btw it's not the point of the question, so will not elaborate). 

The interval file for GATK can be for example a bed file, with 3 columns: chr_name  chr_start  chr_end. I don't have this file, but have the genome and the reads. 

To obtain the intervals per chr/scaf, I proceeded this way: 


converted the alignment to interval file, using bam2bed    (BEDOPS)
extract the columns $1,2,3 (using cut)
get the min &amp; max coordinates per chr/scaff with a small R script:


bd &lt;- read.table('all.bed', h=FALSE)
bd_min &lt;- aggregate( bd$V3 ~ bd$V1 , bd, function(x) min(x))
bd_max &lt;- aggregate( bd$V2 ~ bd$V1 , bd, function(x) max(x))
bd_coord &lt;- merge(bd_min, bd_max, by='bd$V1')
write.table(bd_coord, file='coords.bed', sep='\t', quote=FALSE, col.names=FALSE, row.names=FALSE)


These should thus represent the mapped intervals, conceptually same as not feeding the intervals at all (= considering all the sequences).

The ideas for this:


in the bed file: $1 is be the feature, $2 the start position, $3 the end position
so, I need to get the min of $2 for each unique item in $1(for the start coord) and the max of $3 for each item in $1 (for the end coord)


The output looks plausible:

$ cat coords.bed | head -3
Bla_chrm1   678 43860826
Bla_chrm10  181 20381540
Bla_chrm11  343 20367560


My question here:


is this a correct way to proceed?
is there a standardized way to perform this?


My main concern is that I will have to re-build this "coordinate" files for every GATK run, because I think the coordinates per chr/scaf will shift, even slightly, at each GATK run with different datasets.

My other minor concern, is that this approach is a bit slow (given the 160M lines in the current bed file), so an unix-tools solution will also be accepted. I tried to compute myself the max/min using awk (e.g. awk '$3&gt;max[$1]{max[$1]=$3; row[$1]=$0} END{for (i in row) print row[i]}'), but I get different results than with the R approach...
Not sure if I completely understood your question, but if you want simply an interval of your entire genome  you could do instead:

samtools faidx MyGenome.fasta


Obviously that means that you need access to that, not sure if you have.
The resulting fai file contains a format similar to that:

000000F 33203223        94      60      61
000001F 28828106        33756799        60      61
000002F 27810542        63065468        60      61


Where the first column is your chromosome and the second one your length.
I guess you could then just do a awk '{OFS=FS="\t"}{print $1,"0",$2-1}' to get your file.