Getting assembly of an rsID using ncbi eutils?
Entering edit mode
4.7 years ago
burcakotlu ▴ 40

Deal all,

Formerly, I was getting assembly of an rsID properly with the following code, but it doesn't work anymore. Before assembly was not null but this time it is always null.

Here is my post:

URI uri = null;
uri=newURIBuilder().setScheme("https").setHost("").setPath("/entrez/eutils/efetch.fcgi").setParameter( "db", "snp").setParameter( "id", commaSeparatedRsIdList).setParameter("retmode", "xml").build();

RequestConfigdefaultRequestConfig=RequestConfig.custom().setSocketTimeout(60000).setConnectTimeout(60000).setConnectionRequestTimeout( 60000).setStaleConnectionCheckEnabled( true).build();

CloseableHttpClient httpclient = HttpClients.custom().setDefaultRequestConfig( defaultRequestConfig).build();
HttpPost post = new HttpPost( uri);
post.addHeader( "Content-Type", "application/xml");

CloseableHttpResponse response = httpclient.execute( post);

HttpEntity entity = response.getEntity();

if( response.getEntity() != null){

    InputStream is = entity.getContent();
    reader = xmlInputFactory.createXMLEventReader( is);

    while( reader.hasNext()){

        XMLEvent evt = reader.peek();

        if( !evt.isStartElement()){

        StartElement start = evt.asStartElement();
        String localName = start.getName().getLocalPart();

        if( !localName.toLowerCase().equals( Commons.RS)){


            rs = unmarshaller.unmarshal( reader, Rs.class).getValue();

            for( Assembly as : rs.getAssembly()){
                String groupLabel = as.getGroupLabel();

                if( groupLabel != null){

                    for( Component comp : as.getComponent()){
                        for( MapLoc maploc : comp.getMapLoc()){
                            if( maploc.getPhysMapInt() != null){

                                rsInformation = new RsInformation();

                                // Set groupName
                                rsInformation.setGroupLabel( groupLabel);

                                // starts 31st August 2014
                                // forward or reverse
                                rsInformation.setOrient( Orient.convertStringtoEnum( maploc.getOrient()));
                                // ends 31st August 2014

                                // set rsId
                                rsInformation.setRsId( rs.getRsId());

                                // Set the last successful rsID
                                lastSuccessfullRsID = rs.getRsId();

                                // set chromosome name
                                // This chrName is without "chr"
                                // ex: 2, X, Y, 17

                                rsInformation.setChrNameWithoutChr( comp.getChromosome());

                                // set rsId start position
                                // eutil efetch returns 0-based
                                // coordinates
                                rsInformation.setZeroBasedStart( maploc.getPhysMapInt());

                                // set rsId observed Alleles
                                rsInformation.setSlashSeparatedObservedAlleles( rs.getSequence().getObserved());

                                numberofBasesInTheSNPAtMost = getTheNumberofBasesIntheObservedAlleles( rs.getSequence().getObserved());

                                // set rsId end position
                                // eutil efetch returns 0-based
                                // coordinates
                                rsInformation.setZeroBasedEnd( maploc.getPhysMapInt() + numberofBasesInTheSNPAtMost - 1);

                                rsInformationList.add( rsInformation);

                            }// End of if maploc.getPhysMapInt() is not
                                // null

                        }// End of for each Maploc

                    }// End of for Component

                }// End of IF groupLabel startsWith "GRCh38"


                    ncbiEutilStatistics.setNumberofRsIDsDoesNotMapToAnyAssembly( ncbiEutilStatistics.getNumberofRsIDsDoesNotMapToAnyAssembly() + 1);

                    // Declare rsIDs that does not map to any assembly
                    if( GlanetRunner.shouldLog()) "rsId does not map to any assembly Count: " + ncbiEutilStatistics.getNumberofRsIDsDoesNotMapToAnyAssembly() + " --- rs" + rs.getRsId() + " in the given list doesn't map to any assembly. Since It's assembly group label is null");


            }// End of for Assembly

Thanks in advance, Bur├žak Otlu

assembly rsId ncbi eutils • 1.3k views
Entering edit mode

check the *.xsd/schema file returned by the NCBI and the file you used are the same. Check the namespaces. Recompile your java classes.


Login before adding your answer.

Traffic: 1480 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6