Skip to content

Commit

Permalink
fixed various spec file read issues
Browse files Browse the repository at this point in the history
  • Loading branch information
David Wilson committed Mar 22, 2018
1 parent 7629650 commit 72b1c8e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 42 deletions.
2 changes: 1 addition & 1 deletion alphahouse
Submodule alphahouse updated from d680ec to 6de441
103 changes: 62 additions & 41 deletions src/AlphaImputeSpecFileModule.f90
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,9 @@ subroutine ReadInParameterFile(this,SpecFile)
if (size(second)<4) then
goto 4000
endif
read(second(1),*) this%PercGenoForHD
read(second(2),*) this%PercSnpMiss
read(second(3),*) this%SecondPercGenoForHD
read(second(1),*,ierr=4000) this%PercGenoForHD
read(second(2),*, ierr=4000) this%PercSnpMiss
read(second(3),*, ierr=4000) this%SecondPercGenoForHD

if (toLower(second(4))=="allsnpout") this%outopt=1
if (toLower(second(4))=="editedsnpout") this%outopt=0
Expand All @@ -504,9 +504,9 @@ subroutine ReadInParameterFile(this,SpecFile)
! In case no editing is set and there is a single HD panel, a threshold to determine HD individuals is needed
if (size(second) == 4) then

read(second(1),*) this%PercGenoForHD
read(second(2),*) this%PercSnpMiss
read(second(3),*) this%SecondPercGenoForHD
read(second(1),*,ierr=4000) this%PercGenoForHD
read(second(2),*,ierr=4000) this%PercSnpMiss
read(second(3),*,ierr=4000) this%SecondPercGenoForHD



Expand Down Expand Up @@ -544,14 +544,20 @@ subroutine ReadInParameterFile(this,SpecFile)
allocate(character(len(second(2))) :: this%phasePath)

this%phasePath = second(2)
read(second(3),*) this%nPhaseInternal
read(second(3),*,iostat=stat) this%nPhaseInternal
if (stat /=0) then
write(error_unit,*) "ERROR: number of phasing runs set Incorrectly"
endif
this%nPhaseExternal = this%nPhaseInternal/2
else if(ToLower(trim(second(1))) == "nophase") then
this%noPhasing = 0
this%managephaseon1off0 = 0
else
this%managephaseon1off0 = 1
read(second(1),*) this%nPhaseExternal
read(second(1),*,iostat=stat) this%nPhaseExternal
if (stat /=0) then
write(error_unit,*) "ERROR: number of phasing runs set Incorrectly"
endif
this%nPhaseInternal = 2*this%nPhaseExternal

if(this%nPhaseExternal <1 ) then
Expand Down Expand Up @@ -588,8 +594,10 @@ subroutine ReadInParameterFile(this,SpecFile)


do i=1,this%nPhaseExternal
read(second(i), *) this%CoreAndTailLengths(i)

read(second(i), *,iostat=stat) this%CoreAndTailLengths(i)
if (stat /=0) then
write(error_unit,*) "ERROR: CoreAndTailLengths set Incorrectly"
endif
if (this%nsnp /= 0 ) then
if (this%CoreAndTailLengths(i) > this%nsnp) then

Expand Down Expand Up @@ -645,7 +653,11 @@ subroutine ReadInParameterFile(this,SpecFile)
endif

case("numberofprocessorsavailable")
read(second(1),*) this%useProcs
read(second(1),*, iostat=stat) this%useProcs
if (stat /= 0) then
print*, "Error: numberofproccessors available set incorrectly"
stop
endif
write(error_unit,*) "WARNING: numberofprocessorsavailable is legacy and will be removed in future versions. Please use option ParallelProcessors instead"
if (this%useProcs > OMP_get_num_procs()) then
write(error_unit,*) "WARNING - more processors than are available are specified under numberofprocessorsavailable"
Expand All @@ -655,8 +667,16 @@ subroutine ReadInParameterFile(this,SpecFile)
case("largedatasets")
if (ToLower(trim(second(1)))== "yes") then
this%largedatasets=.true.
read(second(2),*) this%PhaseSubsetSize
read(second(3),*) this%PhaseNIterations
read(second(2),*,iostat=stat) this%PhaseSubsetSize
if (stat /= 0) then
print*, "Error: largedatasets specified incorrectly"
stop
endif
read(second(3),*, iostat=stat) this%PhaseNIterations
if (stat /= 0) then
print*, "Error: largedatasets specified incorrectly"
stop
endif
if (size(second) < 4 ) then
this%iterateMethod = "RandomOrder"
else
Expand All @@ -678,7 +698,11 @@ subroutine ReadInParameterFile(this,SpecFile)
endif

case("minoverlaphaplotype")
read(second(1),*) this%minoverlaphaplotype
read(second(1),*,iostat=stat) this%minoverlaphaplotype
if (stat /= 0) then
print*, "Error: minoverlaphaplotype specified incorrectly"
stop
endif
if (this%minoverlaphaplotype < 0) then
write(error_unit,*) "ERROR: Min minoverlap haplotype size is set incorrectly!"
endif
Expand All @@ -700,7 +724,11 @@ subroutine ReadInParameterFile(this,SpecFile)

! box 6
case("internaliterations")
read(second(1), *) this%InternalIterations
read(second(1), *,iostat=stat) this%InternalIterations
if (stat /= 0) then
print*, "Error: internaliterations specified incorrectly"
stop
endif

case("conservativehaplotypelibraryuse")
if(ToLower(trim(second(1))) == "no") then
Expand All @@ -713,7 +741,11 @@ subroutine ReadInParameterFile(this,SpecFile)
endif

case("wellphasedthreshold")
read(second(1),*) this%WellPhasedThresh
read(second(1),*, iostat=stat) this%WellPhasedThresh
if (stat /= 0) then
print*, "Error: wellphasedthreshold specified incorrectly"
stop
endif

! box 7
case("hmmoption")
Expand All @@ -728,27 +760,6 @@ subroutine ReadInParameterFile(this,SpecFile)
stop
endif

! case("hmmparameters")
! if (.not. allocated(second)) then
! write(error_unit,*) "templatehaplotypes not set correctly"
! stop
! endif

! if (size(second) /= 5) then
! write(error_unit,*) "hmmparameters not set correctly"
! stop
! endif

! read(second(1), *) this%nHapInSubH
! read(second(2), *) this%HmmBurnInRound
! read(second(3), *) this%nRoundsHMM
! read(second(4), *) this%useProcs
! if (this%useProcs > OMP_get_num_procs()) then
! write(error_unit,*) "WARNING - more processors than are available are specified under parallelprocessors"
! write(error_unit,*) this%useProcs, " set vs ",OMP_get_num_procs()," available"
! endif
! read(second(5), * ) this%idum

case("templatehaplotypes")
if (.not. allocated(second)) then
write(error_unit,*) "templatehaplotypes not set correctly"
Expand Down Expand Up @@ -869,8 +880,10 @@ subroutine ReadInParameterFile(this,SpecFile)
case("bypassgeneprob")
write(error_unit,*) "The Geneprob has been moved to legacy and is no longer in use"
case("restartoption")
read(second(1),*) this%restartOption

read(second(1),*, iostat=stat) this%restartOption
if (stat /= 0) then
write(error_unit, *) "ERROR: RESTART OPTION set incorrectly"
endif
if (this%restartoption >2) then
write(error_unit,*) "Error - RestartOption can only be the following:"
write(error_unit,*) "0 - run all"
Expand Down Expand Up @@ -902,7 +915,10 @@ subroutine ReadInParameterFile(this,SpecFile)
write(error_unit,*) this%useProcs, " set vs ",OMP_get_num_procs()," available"
endif
case("resultfolderpath")
read(second(1), *) this%resultFolderPath
read(second(1), *, iostat= stat) this%resultFolderPath
if (stat /=0) then
write(error_unit,*) "ERROR: ResultFolderPath set Incorrectly"
endif
case default
write(*,"(A,A)") trim(tag), " is not valid for the AlphaImpute Spec File."
cycle
Expand All @@ -929,7 +945,10 @@ subroutine ReadInParameterFile(this,SpecFile)
case("usechroms")
allocate(this%usechroms(size(second)))
do i= 1, size(second)
read(second(i), *) this%useChroms(i)
read(second(i), *, iostat=stat) this%useChroms(i)
if (stat /=0) then
write(error_unit,*) "ERROR: usechroms set Incorrectly"
endif

enddo

Expand Down Expand Up @@ -1262,3 +1281,5 @@ end module AlphaImputeSpecFileModule





0 comments on commit 72b1c8e

Please sign in to comment.