This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Getting assembly of an rsID using ncbi eutils?

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: https://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgidb=snp&id=rs2280231%2Crs11057881%2Crs4771910%2Crs944088%2Crs3842844%2Crs2069002%2Crs7163140%2Crs2463370%2Crs1899731%2Crs2905963%2Crs324079%2Crs11878617%2Crs1891215%2Crs618019%2Crs13128%2Crs2070514%2Crs7277299%2Crs790125%2Crs7629063%2Crs9869652%2Crs2257216%2Crs1714014%2Crs9759%2Crs10946279%2Crs6937363%2Crs2515029%2Crs894344&retmode=xml

URI uri = null;
uri=newURIBuilder().setScheme("https").setHost("www.ncbi.nlm.nih.gov").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()){
            reader.nextEvent();
            continue;
        }

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

        if( !localName.toLowerCase().equals( Commons.RS)){
            reader.nextEvent();
            continue;
        }

        try{

            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"

                else{

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

                    // Declare rsIDs that does not map to any assembly
                    if( GlanetRunner.shouldLog())logger.info( "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

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

0 answers

No answers yet.

Log in to answer this question.