A new analysis today reveals the full extent of Edinburgh's segregated school system and casts doubt on whether the city can claim to be delivering genuine comprehensive education.

Over 40% of Edinburgh’s state secondaries have been dominated by pupils from prosperous areas, reflecting a catchment system that rewards parents who can afford to move to better areas.

And 30% of the city's secondaries were dominated by school leavers from poorer parts of the Capital.

At Westminster, Prime Minister Theresa May sparked fury after she supported a new generation of grammar schools, which select pupils on the basis of ability at the age of eleven.

Politicians in Scotland attacked the policy and backed comprehensives, which are non-selective and supposed to include pupils from a range of backgrounds.

However, statistics from Education Scotland – a quango that inspects schools and takes the lead on the curriculum – raises questions about the inclusivity of Edinburgh secondaries.

It is widely known that around 25 per cent of pupils in the capital attend independent schools. Middle class parents also commandeer places in Edinburgh’s top state secondaries by moving into a desirable catchment area.

The quango’s figures reveal the way the catchment system entrenches social division and leaves behind a lottery for everyone else.

Education Scotland provides a school-by-school breakdown of school leavers from 2014/15 and where they live.

The quango relies on five categories in the 2012 Scottish Index of Multiple Deprivation (SIMD) to map out where the leavers are based: on a sliding scale, SIMD 1 includes the most deprived parts of Scotland; and SIMD 5 encompasses the most affluent areas.

In seven of Edinburgh’s twenty-three secondaries, over 60% of the 2014/15 leavers were in either SIMD 1 or 2.

In ten schools, over 60% of the leavers lived in the wealthier SIMD 4 and 5 parts of the city.

At Boroughmuir High, 87% were from SIMD 4 and 5, while less than 10% of leavers were from the two categories at the other end of the spectrum.

James Gillespie’s High School, a five-minute walk from from Boroughmuir, was similar: 78% came from the top two SIMD groups, but only 14% of school leavers were from SIMD 1 and 2.

However, in the neighbouring catchment serving Castlebrae Community High School, up to 93% of school leavers were located in SIMD 1 and 2. The figure was less than 5% for the least deprived categories.

Craigroyston Community High School in the north of the city paints a similar picture: up to 80% of school leavers were from poorer areas, while less than 5% came from SIMD 4 and 5.

At the Wester Hailes Education Centre (WHEC), 88% of leavers were judged to be from the bottom two deprivation categories. Not a single school leaver was from SIMD 4 or 5.

Ten of the city’s 23 secondary schools - including Forrester High, which educated Deputy First Minister John Swinney - have fewer than 15% of their school leavers from the most wealthy SIMD group.

Caveats apply to the figures: SIMD is based on geographical areas and not does identify people. A poor person can be based in a wealthy area, while a middle income earner can live in a relatively deprived part of the city.

However, the data appears to confirm that educational outcomes in Edinburgh are heavily influenced by where you live and whether you have the finances to move into a wealthier catchment.

At Boroughmuir, James Gillespie’s and the Royal High School, the proportion of leavers in 2014/15 who achieved Level 5 or better at literacy and numeracy was 73%, 67% and 72%.

By contrast, the figures for Castlebrae, Craigroyston and WHEC were 21%, 24% and 20%.

Lucy Hunter Blackburn, a researcher at Edinburgh University and education specialist, said: “Having a system that is so socially segregated sets very high challenges for ensuring there’s a genuinely comprehensive system, in which every child, no matter where they live, gets the same educational opportunity and experience.”

Keir Bloomer, the chair of Reform Scotland’s Commission on School Reform, said: “If it could be established that attending a school with a high proportion of disadvantaged pupils holds back individual children, then effective action is needed. This is where the Attainment Challenge should be concentrating. Bussing [moving children by bus from one area to another to achieve greater equality] is not a solution in a democratic society. What, therefore, can be done to to ameliorate the impact of disadvantage in schools where it is concentrated? This has to do with providing better targeted, personalised, culturally enriched education in such schools.”

Councillor Paul Godzik, the Convener of the Education, Children & Families Committee at Edinburgh Council, said: “All Edinburgh schools cater for the full range of young people who attend. Every school in the Capital has children affected by poverty and the outcomes for pupils through positive destinations and exam statistics are continuing to rise. However it is our declared intention to continue to close the gap for those young people who are disadvantaged by poverty and we want all children to get the best possible start in life.”